Initial commit
This commit is contained in:
commit
f1548f10cc
7585 files changed
+1411120
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
export function detectLoop(entry: any, symlinkCache: any): boolean;
|
||||
export function detectLoop(entry: any, symlinkCache: any): boolean;
|
||||
export function initSymlinkCache(): {
|
||||
dir1: {};
|
||||
dir2: {};
|
||||
};
|
||||
export function initSymlinkCache(): {
|
||||
dir1: {};
|
||||
dir2: {};
|
||||
};
|
||||
export function updateSymlinkCache(symlinkCache: any, rootEntry1: any, rootEntry2: any, loopDetected1: any, loopDetected2: any): void;
|
||||
export function updateSymlinkCache(symlinkCache: any, rootEntry1: any, rootEntry2: any, loopDetected1: any, loopDetected2: any): void;
|
||||
export function cloneSymlinkCache(symlinkCache: any): {
|
||||
dir1: {};
|
||||
dir2: {};
|
||||
};
|
||||
export function cloneSymlinkCache(symlinkCache: any): {
|
||||
dir1: {};
|
||||
dir2: {};
|
||||
};
|
||||
//# sourceMappingURL=loopDetector.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"loopDetector.d.ts","sourceRoot":"","sources":["../../../src/symlink/loopDetector.js"],"names":[],"mappings":"AAMC,mEAQC;AARD,mEAQC;AAED;;;EAKC;AALD;;;EAKC;AAED,sIAUC;AAVD,sIAUC;AAED;;;EAKC;AALD;;;EAKC"}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
const fs = require('fs');
|
||||
/**
|
||||
* Provides symlink loop detection to directory traversal algorithm.
|
||||
*/
|
||||
module.exports = {
|
||||
detectLoop(entry, symlinkCache) {
|
||||
if (entry && entry.isSymlink) {
|
||||
const realPath = fs.realpathSync(entry.absolutePath);
|
||||
if (symlinkCache[realPath]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
initSymlinkCache() {
|
||||
return {
|
||||
dir1: {},
|
||||
dir2: {}
|
||||
};
|
||||
},
|
||||
updateSymlinkCache(symlinkCache, rootEntry1, rootEntry2, loopDetected1, loopDetected2) {
|
||||
let symlinkCachePath1, symlinkCachePath2;
|
||||
if (rootEntry1 && !loopDetected1) {
|
||||
symlinkCachePath1 = rootEntry1.isSymlink ? fs.realpathSync(rootEntry1.absolutePath) : rootEntry1.absolutePath;
|
||||
symlinkCache.dir1[symlinkCachePath1] = true;
|
||||
}
|
||||
if (rootEntry2 && !loopDetected2) {
|
||||
symlinkCachePath2 = rootEntry2.isSymlink ? fs.realpathSync(rootEntry2.absolutePath) : rootEntry2.absolutePath;
|
||||
symlinkCache.dir2[symlinkCachePath2] = true;
|
||||
}
|
||||
},
|
||||
cloneSymlinkCache(symlinkCache) {
|
||||
return {
|
||||
dir1: shallowClone(symlinkCache.dir1),
|
||||
dir2: shallowClone(symlinkCache.dir2)
|
||||
};
|
||||
},
|
||||
};
|
||||
function shallowClone(obj) {
|
||||
const cloned = {};
|
||||
Object.keys(obj).forEach(key => {
|
||||
cloned[key] = obj[key];
|
||||
});
|
||||
return cloned;
|
||||
}
|
||||
//# sourceMappingURL=loopDetector.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"loopDetector.js","sourceRoot":"","sources":["../../../src/symlink/loopDetector.js"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExB;;GAEG;AACH,MAAM,CAAC,OAAO,GAAG;IAChB,UAAU,CAAC,KAAK,EAAE,YAAY;QAC7B,IAAI,KAAK,IAAI,KAAK,CAAC,SAAS,EAAE;YAC7B,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YACpD,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;gBAC3B,OAAO,IAAI,CAAA;aACX;SACD;QACD,OAAO,KAAK,CAAA;IACb,CAAC;IAED,gBAAgB;QACf,OAAO;YACN,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,EAAE;SACR,CAAA;IACF,CAAC;IAED,kBAAkB,CAAC,YAAY,EAAE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