mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 11:57:04 +08:00
fix (model): refactoring fixing the loading issue in nested folders
This commit is contained in:
@ -264,13 +264,10 @@ class FileSystem {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
switch(step) {
|
||||||
if (step === "prepare_only") {
|
case "prepare_only": return action_prepare(true);
|
||||||
return action_prepare(true);
|
case "execute_only": return action_execute(true);
|
||||||
} else if (step === "execute_only") {
|
default: return action_prepare().then(action_execute);
|
||||||
return action_execute(true);
|
|
||||||
} else {
|
|
||||||
return action_prepare().then(action_execute);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,8 +281,7 @@ class FileSystem {
|
|||||||
.then(() => this._refresh(destination_path));
|
.then(() => this._refresh(destination_path));
|
||||||
} else {
|
} else {
|
||||||
return this._add(destination_path, "loading")
|
return this._add(destination_path, "loading")
|
||||||
.then(() => origin_path !== destination_path ?
|
.then(() => origin_path !== destination_path ? this._add(origin_path, "loading") : Promise.resolve())
|
||||||
this._add(origin_path, "loading") : Promise.resolve())
|
|
||||||
.then(() => this._refresh(origin_path, destination_path));
|
.then(() => this._refresh(origin_path, destination_path));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -330,12 +326,10 @@ class FileSystem {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (step === "prepare_only") {
|
switch(step) {
|
||||||
return action_prepare(true);
|
case "prepare_only": return action_prepare(true);
|
||||||
} else if (step === "execute_only") {
|
case "execute_only": return action_execute(true);
|
||||||
return action_execute(true);
|
default: return action_prepare().then(action_execute);
|
||||||
} else {
|
|
||||||
return action_prepare().then(action_execute);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,18 +449,6 @@ class FileSystem {
|
|||||||
}
|
}
|
||||||
_add(path, icon) {
|
_add(path, icon) {
|
||||||
return cache.upsert(cache.FILE_PATH, [currentBackend(), currentShare(), dirname(path)], (res) => {
|
return cache.upsert(cache.FILE_PATH, [currentBackend(), currentShare(), dirname(path)], (res) => {
|
||||||
const alreadyExist = res !== null;
|
|
||||||
if (!res || !res.results) {
|
|
||||||
res = {
|
|
||||||
path: path,
|
|
||||||
backend: currentBackend(),
|
|
||||||
share: currentShare(),
|
|
||||||
results: [],
|
|
||||||
access_count: 0,
|
|
||||||
last_access: null,
|
|
||||||
last_update: new Date(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const file = mutateFile({
|
const file = mutateFile({
|
||||||
path: path,
|
path: path,
|
||||||
name: basename(path),
|
name: basename(path),
|
||||||
@ -474,10 +456,21 @@ class FileSystem {
|
|||||||
}, path);
|
}, path);
|
||||||
if (icon) file.icon = icon;
|
if (icon) file.icon = icon;
|
||||||
|
|
||||||
if (!(alreadyExist === false && file.type === "directory")) {
|
if (!res || !res.results) {
|
||||||
// add something in the cache ONLY IF we're not creating a new folder
|
res = {
|
||||||
res.results.push(file);
|
path: dirname(path),
|
||||||
|
backend: currentBackend(),
|
||||||
|
share: currentShare(),
|
||||||
|
results: [],
|
||||||
|
access_count: 0,
|
||||||
|
last_access: null,
|
||||||
|
last_update: new Date(),
|
||||||
|
};
|
||||||
|
if (file.type === "directory") {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
res.results.push(file);
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user