Skip to content

Commit

Permalink
winget-source: recude disk write on force sync
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Jul 25, 2024
1 parent 6789ea8 commit cb04502
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions winget-source/sync-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ async function syncIndex(version, handler) {
}

// update index package
await cacheFileWithURI(sourceFilename, indexBuffer, modifiedDate);
if (updated) {
await cacheFileWithURI(sourceFilename, indexBuffer, modifiedDate);
}
} catch (error) {
try {
await rm(tempDirectory, { recursive: true });
Expand All @@ -78,11 +80,13 @@ await syncIndex(2, async (db) => {
try {
// sync latest package metadata and manifests in parallel
await async.eachLimit(packageURIs, parallelLimit, async (uri) => {
const [metadataBuffer, modifiedDate] = await syncFile(uri, forceSync, false);
const [metadataBuffer, modifiedDate, updated] = await syncFile(uri, forceSync, false);
if (metadataBuffer) {
const manifestURIs = await buildManifestURIsFromPackageMetadata(metadataBuffer);
await async.eachSeries(manifestURIs, async (uri) => await syncFile(uri, forceSync));
await cacheFileWithURI(uri, metadataBuffer, modifiedDate);
if (updated) {
await cacheFileWithURI(uri, metadataBuffer, modifiedDate);
}
}
});
} catch (error) {
Expand Down

0 comments on commit cb04502

Please sign in to comment.