Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Fix changed file SHA1 check
Browse files Browse the repository at this point in the history
  • Loading branch information
Petteri Hirvonen committed Sep 13, 2017
1 parent 232e0b7 commit 6bffdc9
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions StudioHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1175,22 +1175,26 @@ class StudioHelper {
fileStats = fs.statSync(path + '/' + fileName),
changedTime = Math.round(new Date(fileStats.mtime).getTime() / 1000);

// If local file is newer and has different sha1, add it to upload array
if (changedTime > +studioFile.createdAt && studioFileSha1 !== fileStats.sha1) {
// If local file is newer
if (changedTime > +studioFile.createdAt) {
let fileInfo = self.getLocalFileInfo(path + '/' + fileName);

fileUploadArray.push({
'action': 'replace',
'folderId': studioFolderId,
'id': studioFile.id,
'type': fileInfo.type,
'size': fileInfo.size,
'localFolder': path,
'name': fileName,
'sha1': fileInfo.sha1,
'data': fileInfo.data,
'createNewVersion': 1
});
// and if it has different sha1, add it to upload array
if (studioFileSha1 !== fileInfo.sha1) {
//console.log(changedTime > +studioFile.createdAt, studioFileSha1, fileInfo.sha1);
fileUploadArray.push({
'action': 'replace',
'folderId': studioFolderId,
'id': studioFile.id,
'type': fileInfo.type,
'size': fileInfo.size,
'localFolder': path,
'name': fileName,
'sha1': fileInfo.sha1,
'data': fileInfo.data,
'createNewVersion': 1
});
}
}

// Remove it from localFiles array. We only want new files to remain there
Expand Down

0 comments on commit 6bffdc9

Please sign in to comment.