Skip to content

Commit

Permalink
fix: #8
Browse files Browse the repository at this point in the history
  • Loading branch information
MuiseDestiny committed Jan 2, 2024
1 parent 4cc433f commit bd1e797
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/modules/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,32 @@ async function attachNewFile(options: {
Zotero.RecognizeDocument.autoRecognizeItems([attItem]);
// showAttachmentItem(attItem);
}
removeFile(path);
}
}

function removeFile(file: any) {
file = Zotero.File.pathToFile(file);
if (!file.exists()) return;
try {
// remove file
if (!file.isDirectory()) {
file.remove(false);
}
// ... for directories, remove them if no non-hidden files are inside
else {
var files = file.directoryEntries;
while (files.hasMoreElements()) {
var f = files.getNext().QueryInterface(Components.interfaces.nsIFile);
if (!f.isHidden()) return;
}
file.remove(true);
}
} catch (err) {
ztoolkit.log(err)
}
};

/**
* 获取Item的分类路径
* @param item
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit bd1e797

Please sign in to comment.