1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Made file api always return relative paths for list()

This commit is contained in:
Laurent Cozic 2017-06-23 19:09:49 +00:00
parent f96848a6bf
commit ec9dacc2c0
3 changed files with 1 additions and 27 deletions

View File

@ -6,10 +6,6 @@ class FileApiDriverMemory {
this.items_ = [];
}
listReturnsFullPath() {
return true;
}
itemIndexByPath(path) {
for (let i = 0; i < this.items_.length; i++) {
if (this.items_[i].path == path) return i;
@ -55,6 +51,7 @@ class FileApiDriverMemory {
let s = item.path.substr(path.length + 1);
if (s.split('/').length === 1) {
let it = Object.assign({}, item);
it.path = it.path.substr(path.length + 1);
output.push(it);
}
}

View File

@ -12,10 +12,6 @@ class FileApiDriverOneDrive {
return this.api_;
}
listReturnsFullPath() {
return false;
}
itemFilter_() {
return {
select: 'name,file,folder,fileSystemInfo',

View File

@ -17,31 +17,12 @@ class FileApi {
return output;
}
scopeItemToBaseDir_(item) {
if (!this.driver_.listReturnsFullPath()) return item;
let output = Object.assign({}, item);
output.path = item.path.substr(this.baseDir_.length + 1);
return output;
}
scopeItemsToBaseDir_(items) {
if (!this.driver_.listReturnsFullPath()) return items;
let output = [];
for (let i = 0; i < items.length; i++) {
output.push(this.scopeItemToBaseDir_(items[i]));
}
return output;
}
list(path = '', options = null) {
if (!options) options = {};
if (!('includeHidden' in options)) options.includeHidden = false;
this.dlog('list');
return this.driver_.list(this.baseDir_).then((items) => {
items = this.scopeItemsToBaseDir_(items);
if (!options.includeHidden) {
let temp = [];
for (let i = 0; i < items.length; i++) {