Skip to content

Commit

Permalink
fix: File diffing issue
Browse files Browse the repository at this point in the history
Closes #232
  • Loading branch information
Frank Steiler committed Jul 3, 2023
1 parent 1d0f5e9 commit c47b057
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/src/lib/photos-library/model/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class Asset implements PEntity<Asset> {
&& this.fileChecksum === asset.fileChecksum
&& this.fileType.equal(asset.fileType)
&& this.size === asset.size
&& this.withinRange(this.modified, asset.modified, 10);
&& this.withinRange(this.modified, asset.modified, 1000);
}

/**
Expand Down
11 changes: 6 additions & 5 deletions app/src/lib/photos-library/photos-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@ export class PhotosLibrary extends EventEmitter {
async loadAssetsForZone(zone: Zones): Promise<PLibraryEntities<Asset>> {
const libAssets: PLibraryEntities<Asset> = {};
const zonePath = zone === Zones.Primary ? this.primaryAssetDir : this.sharedAssetDir;
(await fs.promises.readdir(zonePath))
.forEach(fileName => {
(await fs.promises.readdir(zonePath, { withFileTypes: true }))
.filter(file => file.isFile() && !PHOTOS_LIBRARY.SAFE_FILES.includes(file.name))
.forEach(file => {
try {
const fileStat = fs.statSync(path.format({
"dir": zonePath,
"base": fileName,
"base": file.name,
}));
const asset = Asset.fromFile(fileName, fileStat, zone);
const asset = Asset.fromFile(file.name, fileStat, zone);
libAssets[asset.getUUID()] = asset;
this.logger.debug(`Loaded asset ${asset.getDisplayName()}`);
} catch (err) {
this.emit(HANDLER_EVENT, new iCPSError(LIBRARY_ERR.INVALID_FILE)
.setWarning()
.addMessage(fileName)
.addMessage(file.name)
.addCause(err));
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/test/unit/sync-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ describe(`Diffing state`, () => {

test(`Only modified changed`, () => {
const remoteAssets = [
new Asset(`somechecksum`, 42, FileType.fromExtension(`png`), 142, getRandomZone(), AssetType.ORIG, `test`, `somekey`, `somechecksum`, `https://icloud.com`, `somerecordname`, false),
new Asset(`somechecksum1`, 42, FileType.fromExtension(`png`), 142, getRandomZone(), AssetType.EDIT, `test1`, `somekey`, `somechecksum1`, `https://icloud.com`, `somerecordname1`, false),
new Asset(`somechecksum`, 42, FileType.fromExtension(`png`), 1420, getRandomZone(), AssetType.ORIG, `test`, `somekey`, `somechecksum`, `https://icloud.com`, `somerecordname`, false),
new Asset(`somechecksum1`, 42, FileType.fromExtension(`png`), 1420, getRandomZone(), AssetType.EDIT, `test1`, `somekey`, `somechecksum1`, `https://icloud.com`, `somerecordname1`, false),
new Asset(`somechecksum2`, 42, FileType.fromExtension(`png`), 42, getRandomZone(), AssetType.EDIT, `test2`, `somekey`, `somechecksum2`, `https://icloud.com`, `somerecordname2`, false),
new Asset(`somechecksum3`, 42, FileType.fromExtension(`png`), 42, getRandomZone(), AssetType.ORIG, `test3`, `somekey`, `somechecksum3`, `https://icloud.com`, `somerecordname3`, false),
];
Expand Down

0 comments on commit c47b057

Please sign in to comment.