mirror of https://github.com/keeweb/keeweb.git
binaries management
This commit is contained in:
parent
545734ba9f
commit
73d1f23f59
|
@ -108,7 +108,12 @@ var EntryModel = Backbone.Model.extend({
|
|||
_attachmentsToModel: function(binaries) {
|
||||
var att = [];
|
||||
_.forEach(binaries, function(data, title) {
|
||||
att.push(AttachmentModel.fromAttachment({ data: data, title: title }));
|
||||
if (data && data.ref) {
|
||||
data = this.file.db.meta.binaries[data.ref];
|
||||
}
|
||||
if (data) {
|
||||
att.push(AttachmentModel.fromAttachment({data: data, title: title}));
|
||||
}
|
||||
}, this);
|
||||
return att;
|
||||
},
|
||||
|
@ -181,7 +186,15 @@ var EntryModel = Backbone.Model.extend({
|
|||
|
||||
addAttachment: function(name, data) {
|
||||
this._entryModified();
|
||||
this.entry.binaries[name] = kdbxweb.ProtectedValue.fromBinary(data);
|
||||
var binaryId;
|
||||
for (var i = 0; ; i++) {
|
||||
if (!this.file.db.meta.binaries[i]) {
|
||||
binaryId = i.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.file.db.meta.binaries[binaryId] = data;
|
||||
this.entry.binaries[name] = { ref: binaryId };
|
||||
this._fillByEntry();
|
||||
},
|
||||
|
||||
|
|
|
@ -255,9 +255,11 @@ var FileModel = Backbone.Model.extend({
|
|||
getData: function(cb) {
|
||||
this.db.cleanup({
|
||||
historyRules: true,
|
||||
customIcons: true
|
||||
customIcons: true,
|
||||
binaries: true
|
||||
});
|
||||
var that = this;
|
||||
this.db.cleanup({ binaries: true });
|
||||
this.db.save(function(data, err) {
|
||||
if (err) {
|
||||
logger.error('Error saving file', that.get('name'), err);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"dropbox": "antelle/dropbox-js#0.10.6",
|
||||
"font-awesome": "~4.4.0",
|
||||
"install": "~1.0.4",
|
||||
"kdbxweb": "~0.3.2",
|
||||
"kdbxweb": "~0.3.3",
|
||||
"normalize.css": "~3.0.3",
|
||||
"pikaday": "~1.3.3",
|
||||
"zepto": "~1.1.6",
|
||||
|
|
Loading…
Reference in New Issue