storage: do not hardcode directory list to synchronize in gadget logic

This commit is contained in:
Nicolas Wavrant 2020-04-10 06:48:51 +02:00
parent 6569a6ffe2
commit fc36423b57
2 changed files with 22 additions and 15 deletions

9
dev/directory_list.txt Normal file
View File

@ -0,0 +1,9 @@
/
/style/
/dev/
/dev/codemirror/
/dev/codemirror/addon/
/dev/codemirror/mode/
/dev/codemirror/theme/
/dev/test/
/priv/

View File

@ -59,19 +59,7 @@
rJS(window)
.ready(function () {
var gadget = this;
gadget.directory_list = [
"/",
"/style/",
"/dev/",
"/dev/codemirror/",
"/dev/codemirror/addon/",
"/dev/codemirror/mode/",
"/dev/codemirror/theme/",
"/dev/test/",
"/priv/",
];
gadget.directory_list = [];
return RSVP.Queue();
})
@ -88,9 +76,19 @@
});
return getDAVStorageConnector(gadget)
.push(function(connector) {
.push(function (connector) {
gadget.dav_storage = connector;
return RSVP.Queue();
return gadget.local_storage.getAttachment("/dev/", "directory_list.txt", {"format": "text"});
})
.push(function (text) {
return text;
}, function (error) {
// We couldn't find the file locally, let's try online.
// This happens probably because it is the first synchro.
return gadget.dav_storage.getAttachment("/dev/", "directory_list.txt", {"format": "text"});
})
.push(function (text) {
gadget.directory_list = text.split('\n');
});
})