Remove tmp-* directories when attachment download fails. Closes #1128
This commit is contained in:
parent
43dad62150
commit
74d358bd19
|
@ -326,6 +326,7 @@ Zotero.Attachments = new function(){
|
|||
|
||||
yield deferred.promise;
|
||||
let sample = yield Zotero.File.getSample(tmpFile);
|
||||
try {
|
||||
if (contentType == 'application/pdf' &&
|
||||
Zotero.MIME.sniffForMIMEType(sample) != 'application/pdf') {
|
||||
let errString = "Downloaded PDF did not have MIME type "
|
||||
|
@ -369,11 +370,8 @@ Zotero.Attachments = new function(){
|
|||
// Refetch item to update path
|
||||
attachmentItem.attachmentPath = destFile.path;
|
||||
yield attachmentItem.save(saveOptions);
|
||||
}.bind(this))
|
||||
.catch(function (e) {
|
||||
Zotero.debug(e, 1);
|
||||
|
||||
// Clean up
|
||||
}.bind(this));
|
||||
} catch (e) {
|
||||
try {
|
||||
if (tmpDir && tmpDir.exists()) {
|
||||
tmpDir.remove(true);
|
||||
|
@ -385,9 +383,8 @@ Zotero.Attachments = new function(){
|
|||
catch (e) {
|
||||
Zotero.debug(e, 1);
|
||||
}
|
||||
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
|
||||
// We don't have any way of knowing that the file is flushed to disk,
|
||||
// so we just wait a second before indexing and hope for the best.
|
||||
|
|
Loading…
Reference in New Issue
Block a user