mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
Fixes c9/core+200 - correct information in the fs cache
This commit is contained in:
parent
5b946753ed
commit
fbfb17f46b
@ -56,20 +56,20 @@ define(function(require, exports, module) {
|
||||
removeSingleNode(e);
|
||||
});
|
||||
|
||||
watcher.on("change", function(e) {
|
||||
onstat({path: e.path, result: [null, e.stat]});
|
||||
watcher.on("change.all", function(e) {
|
||||
onstat({ path: e.path, result: [null, e.stat] });
|
||||
});
|
||||
|
||||
watcher.on("directory", function(e) {
|
||||
watcher.on("directory.all", function(e) {
|
||||
// @todo make onreaddir incremental
|
||||
onreaddir({path: e.path, result: [null, e.files]});
|
||||
onreaddir({ path: e.path, result: [null, e.files] });
|
||||
});
|
||||
|
||||
// Read
|
||||
fs.on("beforeReaddir", function (e) {
|
||||
var node = findNode(e.path);
|
||||
if (!node)
|
||||
return; //Parent is not visible
|
||||
return; // Parent is not visible
|
||||
|
||||
// Indicate this directory is being read
|
||||
model.setAttribute(node, "status", "loading");
|
||||
@ -147,6 +147,8 @@ define(function(require, exports, module) {
|
||||
fs.on("afterReaddir", onreaddir, plugin);
|
||||
|
||||
function onstat(e) {
|
||||
var stat;
|
||||
|
||||
if (!e.error) {
|
||||
// update cache
|
||||
var there = true;
|
||||
@ -168,14 +170,14 @@ define(function(require, exports, module) {
|
||||
deleteNode(node);
|
||||
}
|
||||
else {
|
||||
var stat = e.result[1];
|
||||
stat = e.result[1];
|
||||
if (typeof stat != "object")
|
||||
stat = null;
|
||||
createNode(e.path, stat);
|
||||
}
|
||||
}
|
||||
else if (there) {
|
||||
var stat = e.result[1];
|
||||
stat = e.result[1];
|
||||
if (typeof stat != "object")
|
||||
stat = null;
|
||||
createNode(e.path, stat, node);
|
||||
@ -202,18 +204,19 @@ define(function(require, exports, module) {
|
||||
|
||||
function addSingleNode(e, isFolder, linkInfo) {
|
||||
var node = findNode(e.path);
|
||||
if (node) return; //Node already exists
|
||||
if (node) return; // Node already exists
|
||||
|
||||
if (!showHidden && isFileHidden(e.path))
|
||||
return;
|
||||
|
||||
var parent = findNode(dirname(e.path));
|
||||
if (parent) { //Dir is in cache
|
||||
if (parent) { // Dir is in cache
|
||||
var stat = isFolder
|
||||
? {mime : "folder"}
|
||||
? { mime : "folder" }
|
||||
: (linkInfo
|
||||
? {link: true, linkStat: {fullPath: linkInfo}}
|
||||
: null);
|
||||
? { link: true, linkStat: { fullPath: linkInfo } }
|
||||
: {});
|
||||
stat.mtime = Math.floor(Date.now() / 1000);
|
||||
node = createNode(e.path, stat);
|
||||
|
||||
emit("add", {path : e.path, node : node});
|
||||
@ -563,7 +566,10 @@ define(function(require, exports, module) {
|
||||
node.mtime = stat.mtime;
|
||||
if (original_stat || stat.linkErr)
|
||||
node.link = stat.fullPath || stat.linkErr;
|
||||
node.isFolder = isFolder;
|
||||
if (isFolder)
|
||||
node.isFolder = isFolder;
|
||||
else
|
||||
delete node.isFolder;
|
||||
}
|
||||
|
||||
if (node.isFolder && !node.map)
|
||||
@ -736,6 +742,10 @@ define(function(require, exports, module) {
|
||||
});
|
||||
plugin.on("unload", function(){
|
||||
loaded = false;
|
||||
showHidden = false;
|
||||
hiddenFilePattern = "";
|
||||
hiddenFileRe = /^$/;
|
||||
orphans = {};
|
||||
});
|
||||
|
||||
/***** Register and define API *****/
|
||||
|
||||
@ -188,6 +188,7 @@ define(function(require, exports, module) {
|
||||
|
||||
function fireWatcherEvent(eventSuffix) {
|
||||
if (event == "error") {
|
||||
if (eventSuffix != ".all") return;
|
||||
// console.error("[watchers] received error for", path, err, stat);
|
||||
}
|
||||
else if (event == "delete") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user