dropbox autosave

pull/8/head
Antelle 2015-10-25 19:55:28 +03:00
parent 2e6cc83ad7
commit e3ccb1ee12
2 changed files with 18 additions and 1 deletions

View File

@ -10,6 +10,7 @@
- [ ] switch view
- [ ] lock without closing
- [ ] merge
- [ ] show sync state
- [ ] dropbox keyfiles
- [ ] generation templates
- [ ] advanced search

View File

@ -4,6 +4,7 @@ var Backbone = require('backbone'),
GroupCollection = require('../collections/group-collection'),
GroupModel = require('./group-model'),
Launcher = require('../comp/launcher'),
DropboxLink = require('../comp/dropbox-link'),
kdbxweb = require('kdbxweb'),
demoFileData = require('base64!../../resources/Demo.kdbx');
@ -160,7 +161,22 @@ var FileModel = Backbone.Model.extend({
},
autoSave: function() {
Launcher.writeFile(this.get('path'), this.getData());
this.set('syncing', true);
switch (this.get('storage')) {
case 'file':
Launcher.writeFile(this.get('path'), this.getData());
this.saved(this.get('path'), this.get('storage'));
break;
case 'dropbox':
DropboxLink.saveFile(this.get('path'), this.getData(), true, (function(err) {
if (!err) {
this.saved(this.get('path'), this.get('storage'));
}
}).bind(this));
break;
default:
throw 'Unknown storage; cannot auto save';
}
},
getData: function() {