This commit is contained in:
Antelle 2015-12-08 00:20:18 +03:00
parent 2d5fb037fd
commit 1227698aeb
4 changed files with 10 additions and 4 deletions

View File

@ -22,7 +22,7 @@ var FileInfoCollection = Backbone.Collection.extend({
},
getLast: function () {
this.max(function(file) { return file.get('openDate'); });
return this.first();
},
getMatch: function (storage, name, path) {

View File

@ -302,8 +302,8 @@ var AppModel = Backbone.Model.extend({
if (that.files.get(file.id)) {
return callback('Duplicate file id');
}
var cacheId = fileInfo && fileInfo.id || IdGenerator.uuid();
if (params.availOffline && updateCacheOnSuccess) {
var cacheId = fileInfo && fileInfo.id || IdGenerator.uuid();
Storage.cache.save(cacheId, params.fileData, function(err) {
if (err) {
file.set('availOffline', false);
@ -315,6 +315,9 @@ var AppModel = Backbone.Model.extend({
if (!params.availOffline && fileInfo && !fileInfo.get('modified')) {
that.removeFileInfo(fileInfo.id);
}
if (params.storage === 'file') {
that.addToLastOpenFiles(file, cacheId, params.rev);
}
that.addFile(file);
});
},

View File

@ -65,7 +65,10 @@ var StorageFileCache = {
return callback && callback(err);
}
try {
Launcher.deleteFile(this.getPath(id));
var path = this.getPath(id);
if (Launcher.fileExists(path)) {
Launcher.deleteFile(path);
}
if (callback) { callback(); }
} catch(e) {
console.error('Error removing from cache', id, e);

View File

@ -59,7 +59,7 @@ var OpenView = Backbone.View.extend({
getLastOpenFiles: function() {
return this.model.fileInfos.map(function(f) {
var icon;
switch (f.storage) {
switch (f.get('storage')) {
case 'dropbox':
icon = 'dropbox';
break;