Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function onPath(path) {
// Write the symlink
if (path !== row.path) {
row.call(fs.deleteEntry);
}
return row.call(path, fs.writeEntry, {
mode: modes.sym,
hash: hash
});
}
}
function onHash(hash) {
if (row.path === result.path) {
return onPath(row.path);
}
// If the user changed the path, we need to move things
makeUnique(rootRow, result.path, modes.sym, onPath);
function onPath(path) {
// Write the symlink
if (path !== row.path) {
row.call(fs.deleteEntry);
}
return row.call(path, fs.writeEntry, {
mode: modes.sym,
hash: hash
});
}
}
});
rules.push({
path: newPath,
root: root,
hash: ruleEntry.hash
});
}
if (!entry) {
// If you get here, the entry didn't match
// In raw-mode this is a no-find.
if (!bake) break;
// In bake mode, look for rule that may serve this path.
return searchRules();
}
if (bake && (entry.mode === modes.sym)) {
if (!check("blob", entry.hash)) return;
var blob = storage.get(entry.hash);
var link = binary.toUnicode(blob);
var rest = parts.slice(index + 1).join("/");
var linkPath = pathJoin(partial, link, rest);
return resolvePath(linkPath, bake, callback);
}
// We're good, move on!
mode = entry.mode;
hash = entry.hash;
partial = newPath;
if (mode === modes.commit) root = partial;
index++;
} else {
break;
readEntry(path, function (err, entry) {
if (err) return callback(err);
if (!entry.hash) return callback(err || new Error("Missing entry"));
if (entry.mode !== modes.sym) return callback("Not a symlink");
var repo = repos[entry.root];
repo.loadAs("blob", entry.hash, function (err, blob) {
if (err) return callback(err);
try { entry.link = binary.toUnicode(blob); }
catch (err) { return callback(err); }
callback(null, entry);
});
});
}
repo.loadAs("blob", entry.hash, function (err, content) {
if (!content) return callback(err);
if (entry.mode === modes.sym) {
content = options.decrypt(content);
}
callback(null, content);
});
}
function updateIcon() {
var value =
(errorMessage ? "icon-attention" :
busy ? "icon-spin1 animate-spin" :
mode === modes.sym ? "icon-link" :
mode === modes.file ? "icon-doc" :
mode === modes.exec ? "icon-cog" :
mode === modes.commit ? "icon-fork" :
open ? "icon-folder-open" : "icon-folder") +
(mode === modes.commit ? " tight" : "");
$.icon.setAttribute("class", value);
var title = modes.toType(mode) + " " + hash;
if (errorMessage) title += "\n" + errorMessage;
$.icon.setAttribute("title", title);
if (mode !== modes.commit) {
if ($.folder) {
$.row.removeChild($.folder);
delete $.folder;
}
}
else {
row.call(fs.saveAs, "blob", result.target, function (hash) {
addChild(row, name, modes.sym, hash);
});
});
var files = Object.keys(toWrite).map(function (path) {
var content = toWrite[path];
delete toWrite[path];
var mode = modes.blob;
if (options.shouldEncrypt && options.shouldEncrypt(path)) {
mode = modes.sym;
content = options.encrypt(content);
}
return {
path: path,
mode: mode,
content: content
};
});
return files;
function activateRow(row, hard) {
if (row.mode === modes.tree || row.mode === modes.commit) {
if (openPaths[row.path]) closeTree(row);
else openTree(row);
}
else if (modes.isFile(row.mode)) {
activateDoc(row, hard);
}
else if (row.mode === modes.sym) {
editSymLink(row);
}
else {
row.fail(new Error("Unknown node mode"));
}
}