Remove deleted files from DB

This commit is contained in:
Andras Schmelczer 2025-03-20 22:26:19 +00:00
parent 1b7ab8b038
commit e7ec41eafe
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 8 additions and 1 deletions

View file

@ -151,6 +151,11 @@ export class Database {
// No need to save as Promises don't get serialized // No need to save as Promises don't get serialized
} }
public removeDocument(find: DocumentRecord): void {
this.documents = this.documents.filter((document) => document !== find);
this.save();
}
public getLatestDocumentByRelativePath( public getLatestDocumentByRelativePath(
find: RelativePath find: RelativePath
): DocumentRecord | undefined { ): DocumentRecord | undefined {

View file

@ -119,6 +119,8 @@ export class Syncer {
); );
resolve(); resolve();
this.database.removeDocument(document);
} catch (e) { } catch (e) {
reject(e); reject(e);
} finally { } finally {
@ -263,7 +265,7 @@ export class Syncer {
const lastSeenUpdateId = this.database.getLastSeenUpdateId(); const lastSeenUpdateId = this.database.getLastSeenUpdateId();
if ( if (
lastSeenUpdateId === undefined || lastSeenUpdateId === undefined ||
remote.lastUpdateId > lastSeenUpdateId lastSeenUpdateId < remote.lastUpdateId
) { ) {
this.database.setLastSeenUpdateId(remote.lastUpdateId); this.database.setLastSeenUpdateId(remote.lastUpdateId);
} }