Skip to content

Commit

Permalink
Read mtime from both properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Jul 9, 2018
1 parent ef478a9 commit ea7794d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ OC.FileUpload.prototype = {
return this.getFile().name;
},

getLastModified: function() {
var file = this.getFile();
if (file.lastModifiedDate) {
return file.lastModifiedDate.getTime() / 1000;
}
else if (file.lastModified) {
return file.lastModified / 1000;
}
return null;
},

setTargetFolder: function(targetFolder) {
this._targetFolder = targetFolder;
},
Expand Down Expand Up @@ -238,9 +249,10 @@ OC.FileUpload.prototype = {
this.data.headers['OC-Autorename'] = '1';
}

if (file.lastModified) {
var lastModified = this.getLastModified();
if (lastModified) {
// preserve timestamp
this.data.headers['X-OC-Mtime'] = file.lastModified / 1000;
this.data.headers['X-OC-Mtime'] = lastModified;
}

var userName = this.uploader.davClient.getUserName();
Expand Down Expand Up @@ -287,11 +299,11 @@ OC.FileUpload.prototype = {
}

var uid = OC.getCurrentUser().uid;
var mtime = this.getFile().lastModified;
var mtime = this.getLastModified();
var size = this.getFile().size;
var headers = {};
if (mtime) {
headers['X-OC-Mtime'] = mtime / 1000;
headers['X-OC-Mtime'] = mtime;
}
if (size) {
headers['OC-Total-Length'] = size;
Expand Down

0 comments on commit ea7794d

Please sign in to comment.