Skip to content

Commit

Permalink
fix: renaming attachments would retrigger upload
Browse files Browse the repository at this point in the history
  • Loading branch information
stravo1 committed Jul 9, 2024
1 parent 27c3dfd commit 42104e7
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,10 +1434,8 @@ export default class driveSyncPlugin extends Plugin {
/\//g,
"."
);
let newSafeFilename = newFile.path.replace(
/\//g,
"."
);
let newSafeFilename =
newFile.path.replace(/\//g, ".");
await this.adapter.remove(
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${oldSafeFilename}`
);
Expand Down Expand Up @@ -1563,7 +1561,10 @@ export default class driveSyncPlugin extends Plugin {
await this.writeToVerboseLogFile(
"LOG: Connectivity lost, not uploading files to Google Drive"
);
if (e instanceof TFile && !/-synced\.*/.test(e.path)) {
if (
e instanceof TFile &&
!this.cloudFiles.includes(e.path)
) {
if (e.extension != "md") {
await this.writeToVerboseLogFile(
"LOG: created attachment while offline"
Expand All @@ -1584,7 +1585,10 @@ export default class driveSyncPlugin extends Plugin {
return;
}

if (e instanceof TFile && !/-synced\.*/.test(e.path)) {
if (
e instanceof TFile &&
!this.cloudFiles.includes(e.path)
) {
if (e.extension != "md") {
await this.writeToVerboseLogFile(
"LOG: created attachment while online"
Expand Down Expand Up @@ -1614,11 +1618,8 @@ export default class driveSyncPlugin extends Plugin {
);
return;
}

let convertedSafeFilename = e.path.replace(
/\//g,
"."
);

let convertedSafeFilename = e.path.replace(/\//g, ".");
try {
await this.adapter.remove(
`${ATTACHMENT_TRACKING_FOLDER_NAME}/${convertedSafeFilename}`
Expand Down

0 comments on commit 42104e7

Please sign in to comment.