From 0d72e5f9a02a9fcd450565bf61f2a10c404b754c Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Sun, 4 Sep 2022 13:22:47 +0200 Subject: [PATCH] revert explicit dir close --- dist/restore/index.js | 16 +++------------- dist/save/index.js | 16 +++------------- src/cleanup.ts | 16 +++------------- 3 files changed, 9 insertions(+), 39 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 92d1161..fb6f17e 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -64618,7 +64618,6 @@ async function cleanTargetDir(targetDir, packages, checkTimestamp = false) { await rm(dir.path, dirent); } } - await dir.close(); } async function cleanProfileTarget(profileDir, packages, checkTimestamp = false) { lib_core.debug(`cleaning profile directory "${profileDir}"`); @@ -64662,7 +64661,6 @@ async function cleanBin() { await rm(dir.path, dirent); } } - await dir.close(); } async function cleanRegistry(packages) { // `.cargo/registry/src` @@ -64674,16 +64672,14 @@ async function cleanRegistry(packages) { if (dirent.isDirectory()) { // eg `.cargo/registry/index/github.com-1ecc6299db9ec823` // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772` - const dir = await fs.promises.opendir(path.join(indexDir.path, dirent.name)); + const dirPath = path.join(indexDir.path, dirent.name); // for a git registry, we can remove `.cache`, as cargo will recreate it from git - if (await exists(path.join(dir.path, ".git"))) { - await rmRF(path.join(dir.path, ".cache")); + if (await exists(path.join(dirPath, ".git"))) { + await rmRF(path.join(dirPath, ".cache")); } - await dir.close(); // TODO: else, clean `.cache` based on the `packages` } } - await indexDir.close(); const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`)); // `.cargo/registry/cache` const cacheDir = await fs.promises.opendir(path.join(CARGO_HOME, "registry", "cache")); @@ -64698,10 +64694,8 @@ async function cleanRegistry(packages) { await rm(dir.path, dirent); } } - await dir.close(); } } - await cacheDir.close(); } async function cleanGit(packages) { const coPath = path.join(CARGO_HOME, "git", "checkouts"); @@ -64730,7 +64724,6 @@ async function cleanGit(packages) { await rm(dir.path, dirent); } } - await dir.close(); } catch { } // clean the checkouts @@ -64751,9 +64744,7 @@ async function cleanGit(packages) { await rm(refsDir.path, dirent); } } - await refsDir.close(); } - await dir.close(); } catch { } } @@ -64786,7 +64777,6 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) { await rm(dir.path, dirent); } } - await dir.close(); } async function rm(parent, dirent) { try { diff --git a/dist/save/index.js b/dist/save/index.js index 2c4bf8d..3cc65b7 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -64618,7 +64618,6 @@ async function cleanTargetDir(targetDir, packages, checkTimestamp = false) { await rm(dir.path, dirent); } } - await dir.close(); } async function cleanProfileTarget(profileDir, packages, checkTimestamp = false) { core.debug(`cleaning profile directory "${profileDir}"`); @@ -64662,7 +64661,6 @@ async function cleanBin() { await rm(dir.path, dirent); } } - await dir.close(); } async function cleanRegistry(packages) { // `.cargo/registry/src` @@ -64674,16 +64672,14 @@ async function cleanRegistry(packages) { if (dirent.isDirectory()) { // eg `.cargo/registry/index/github.com-1ecc6299db9ec823` // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772` - const dir = await external_fs_default().promises.opendir(external_path_default().join(indexDir.path, dirent.name)); + const dirPath = external_path_default().join(indexDir.path, dirent.name); // for a git registry, we can remove `.cache`, as cargo will recreate it from git - if (await exists(external_path_default().join(dir.path, ".git"))) { - await rmRF(external_path_default().join(dir.path, ".cache")); + if (await exists(external_path_default().join(dirPath, ".git"))) { + await rmRF(external_path_default().join(dirPath, ".cache")); } - await dir.close(); // TODO: else, clean `.cache` based on the `packages` } } - await indexDir.close(); const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`)); // `.cargo/registry/cache` const cacheDir = await external_fs_default().promises.opendir(external_path_default().join(CARGO_HOME, "registry", "cache")); @@ -64698,10 +64694,8 @@ async function cleanRegistry(packages) { await rm(dir.path, dirent); } } - await dir.close(); } } - await cacheDir.close(); } async function cleanGit(packages) { const coPath = external_path_default().join(CARGO_HOME, "git", "checkouts"); @@ -64730,7 +64724,6 @@ async function cleanGit(packages) { await rm(dir.path, dirent); } } - await dir.close(); } catch { } // clean the checkouts @@ -64751,9 +64744,7 @@ async function cleanGit(packages) { await rm(refsDir.path, dirent); } } - await refsDir.close(); } - await dir.close(); } catch { } } @@ -64786,7 +64777,6 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) { await rm(dir.path, dirent); } } - await dir.close(); } async function rm(parent, dirent) { try { diff --git a/src/cleanup.ts b/src/cleanup.ts index 1b7eaee..25cd030 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -29,7 +29,6 @@ export async function cleanTargetDir(targetDir: string, packages: Packages, chec await rm(dir.path, dirent); } } - await dir.close(); } async function cleanProfileTarget(profileDir: string, packages: Packages, checkTimestamp = false) { @@ -84,7 +83,6 @@ export async function cleanBin() { await rm(dir.path, dirent); } } - await dir.close(); } export async function cleanRegistry(packages: Packages) { @@ -98,17 +96,15 @@ export async function cleanRegistry(packages: Packages) { if (dirent.isDirectory()) { // eg `.cargo/registry/index/github.com-1ecc6299db9ec823` // or `.cargo/registry/index/index.crates.io-e139d0d48fed7772` - const dir = await fs.promises.opendir(path.join(indexDir.path, dirent.name)); + const dirPath = path.join(indexDir.path, dirent.name); // for a git registry, we can remove `.cache`, as cargo will recreate it from git - if (await exists(path.join(dir.path, ".git"))) { - await rmRF(path.join(dir.path, ".cache")); + if (await exists(path.join(dirPath, ".git"))) { + await rmRF(path.join(dirPath, ".cache")); } - await dir.close(); // TODO: else, clean `.cache` based on the `packages` } } - await indexDir.close(); const pkgSet = new Set(packages.map((p) => `${p.name}-${p.version}.crate`)); @@ -125,10 +121,8 @@ export async function cleanRegistry(packages: Packages) { await rm(dir.path, dirent); } } - await dir.close(); } } - await cacheDir.close(); } export async function cleanGit(packages: Packages) { @@ -159,7 +153,6 @@ export async function cleanGit(packages: Packages) { await rm(dir.path, dirent); } } - await dir.close(); } catch {} // clean the checkouts @@ -180,9 +173,7 @@ export async function cleanGit(packages: Packages) { await rm(refsDir.path, dirent); } } - await refsDir.close(); } - await dir.close(); } catch {} } @@ -219,7 +210,6 @@ async function rmExcept(dirName: string, keepPrefix: Set, checkTimestamp await rm(dir.path, dirent); } } - await dir.close(); } async function rm(parent: string, dirent: fs.Dirent) {