Skip to content

Commit

Permalink
fix: offline sync support for new attachment tracking, delete trigger…
Browse files Browse the repository at this point in the history
… deleted tracking info
  • Loading branch information
stravo1 committed Jul 9, 2024
1 parent 52e60cf commit 27c3dfd
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,35 @@ export default class driveSyncPlugin extends Plugin {
this.renamedWhileOffline.set(newFile.path, id!);
this.renamedWhileOffline.delete(oldpath);
this.finalNamesForFileID.set(id!, newFile.path);
if (newFile instanceof TFile) {
if (newFile.extension != "md") {
try {
let oldSafeFilename = oldpath.replace(
/\//g,
"."
);
let newSafeFilename = newFile.path.replace(
/\//g,
"."
);
await this.adapter.remove(
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${oldSafeFilename}`
);
await this.app.vault.create(
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${newSafeFilename}`,
""
);
} catch (err) {
await this.writeToVerboseLogFile(
`LOG: ${ATTACHMENT_TRACKING_FOLDER_NAME}/${oldpath.replace(
/\//g,
"."
)} could not be renamed`
);
await this.writeToErrorLogFile(err);
}
}
}
}
await this.writeToPendingSyncFile();
return;
Expand Down Expand Up @@ -1585,6 +1614,22 @@ export default class driveSyncPlugin extends Plugin {
);
return;
}

let convertedSafeFilename = e.path.replace(
/\//g,
"."
);
try {
await this.adapter.remove(
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${convertedSafeFilename}`
);
} catch (err) {
await this.writeToErrorLogFile(err);
await this.writeToVerboseLogFile(
"LOG: Could not delete " +
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${convertedSafeFilename}`
);
}

try {
if (!this.connectedToInternet) {
Expand Down

0 comments on commit 27c3dfd

Please sign in to comment.