Hi,
As you advise, I searched a solution by myself before submitting this issue 😉 I took quite some time to find a workaround and try to give you maximum information to understand the situation.
I used Meteor-Files 1.6.6 without any problem and I upgraded Meteor from 1.3.4.4 to 1.4.2.3. With this upgrade, I updated Meteor-Files into 1.7.6. I did not noticed anything in development environment but when I deployed in production, each file I uploaded were removed immediately.
I run my application in production with Nginx and Phusion Passenger on Ubuntu 16.04.
App 26871 stdout: [FilesCollection] [File Start Method] TestFile.xlsx - HoWhviCGcmJ67bSjG
App 26871 stdout: [FilesCollection] [Upload] [Start Method] Got #-1/1 chunks, dst: TestFile.xlsx
App 26871 stdout: [FilesCollection] [Upload] [DDP] Got #1/1 chunks, dst: TestFile.xlsx
App 26871 stdout: [FilesCollection] [Upload] [DDP] Got #-1/1 chunks, dst: TestFile.xlsx
App 26871 stdout: [FilesCollection] [Upload] [finish(ing)Upload] -> assets/path/files/HoWhviCGcmJ67bSjG.xlsx
App 26871 stdout: [FilesCollection] [Upload] [finish(ed)Upload] -> assets/path/files/HoWhviCGcmJ67bSjG.xlsx
App 26871 stdout: [FilesCollection] [_preCollectionCursor.observe] [removed]: HoWhviCGcmJ67bSjG
App 26871 stdout: [FilesCollection] [_preCollectionCursor.observe] [removeUnfinishedUpload]: assets/path/files/HoWhviCGcmJ67bSjG.xlsx
I downgraded to Meteor-Files 1.7.5 and did not observe this behavior
App 30506 stdout: [FilesCollection] [File Start Method] TestFile.xlsx - ctt4jBvctNgxRj954
App 30506 stdout: [FilesCollection] [Upload] [Start Method] Got #-1/1 chunks, dst: TestFile.xlsx
App 30506 stdout: [FilesCollection] [Upload] [DDP] Got #1/1 chunks, dst: TestFile.xlsx
App 30506 stdout: [FilesCollection] [Upload] [DDP] Got #-1/1 chunks, dst: TestFile.xlsx
App 30506 stdout: [FilesCollection] [Upload] [finish(ing)Upload] -> assets/path/files/ctt4jBvctNgxRj954.xlsx
App 30506 stdout: [FilesCollection] [Upload] [finish(ed)Upload] -> assets/path/files/ctt4jBvctNgxRj954.xlsx
App 30506 stdout: [FilesCollection] [_preCollectionCursor.observeChanges] [removed]: ctt4jBvctNgxRj954
As I debugged on core mode directly in compiled javascript code. I added just following line to see if isFinished flag was well updated. Strangely, that solved the problem.
FilesCollection.prototype._finishUpload = Meteor.isServer ? function (result, opts, cb) { //
var self; //
if (this.debug) { //
console.info("[FilesCollection] [Upload] [finish(ing)Upload] -> " + result.path); //
} //
fs.chmod(result.path, this.permissions, NOOP); //
self = this; //
result.type = this._getMimeType(opts.file); //
result["public"] = this["public"]; //
this.collection.insert(_.clone(result), function (error, _id) { //
if (error) { //
cb && cb(error); //
if (self.debug) { //
console.error('[FilesCollection] [Upload] [_finishUpload] Error:', error); //
} //
} else { //
self._preCollection.update({ //
_id: opts.fileId //
}, { //
$set: { //
isFinished: true //
} //
}, function () { //
// LINE ADDED TO DEBUG ////////////////////////////////////////////
console.info(self._preCollection.findOne({ _id: opts.fileId })); //
///////////////////////////////////////////////////////////////////
self._preCollection.remove({ //
_id: opts.fileId //
}, function (error) { //
if (error) { //
cb && cb(error); //
if (self.debug) { //
console.error('[FilesCollection] [Upload] [_finishUpload] Error:', error); //
} //
} else { //
result._id = _id; //
if (self.debug) { //
console.info("[FilesCollection] [Upload] [finish(ed)Upload] -> " + result.path); //
} //
self.onAfterUpload && self.onAfterUpload.call(self, result); //
self.emit('afterUpload', result); //
cb && cb(null, result); //
} //
}); //
}); //
} //
}); //
} : void 0; //
Hi,
As you advise, I searched a solution by myself before submitting this issue 😉 I took quite some time to find a workaround and try to give you maximum information to understand the situation.
I used Meteor-Files 1.6.6 without any problem and I upgraded Meteor from 1.3.4.4 to 1.4.2.3. With this upgrade, I updated Meteor-Files into 1.7.6. I did not noticed anything in development environment but when I deployed in production, each file I uploaded were removed immediately.
I run my application in production with Nginx and Phusion Passenger on Ubuntu 16.04.
I downgraded to Meteor-Files 1.7.5 and did not observe this behavior
As I debugged on core mode directly in compiled javascript code. I added just following line to see if isFinished flag was well updated. Strangely, that solved the problem.