remove commented out code

This commit is contained in:
joshuaboud 2022-05-17 12:59:18 -03:00
parent 6a22c9d758
commit 58e7fe61c7
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E

View File

@ -89,145 +89,6 @@ export default {
} }
} }
// const parseModeStr = (cwd, entry, modeStr, linkTargetRaw = null) => {
// const procs = [];
// Object.assign(entry, {
// permissions: {
// owner: {
// read: modeStr[1] !== '-',
// write: modeStr[2] !== '-',
// execute: modeStr[3] !== '-',
// },
// group: {
// read: modeStr[4] !== '-',
// write: modeStr[5] !== '-',
// execute: modeStr[6] !== '-',
// },
// other: {
// read: modeStr[7] !== '-',
// write: modeStr[8] !== '-',
// execute: modeStr[9] !== '-',
// },
// acl: modeStr[10] === '+' ? {} : null,
// }
// });
// switch (modeStr[0]) {
// case 'd':
// entry.type = 'directory';
// break;
// case '-':
// entry.type = 'file';
// break;
// case 'p':
// entry.type = 'pipe';
// break;
// case 'l':
// entry.type = 'link';
// if (linkTargetRaw) {
// entry.target = {
// rawPath: linkTargetRaw,
// path: canonicalPath(linkTargetRaw.replace(/^(?!\/)/, cwd + '/')),
// };
// procs.push(
// useSpawn(['stat', '-c', '%A', entry.target.path]).promise()
// .then(state => {
// parseModeStr(cwd, entry.target, state.stdout.trim());
// entry.target.broken = false;
// })
// .catch(() => {
// entry.target.broken = true;
// })
// );
// }
// break;
// case 's':
// entry.type = 'socket';
// break;
// case 'c':
// entry.type = 'character';
// break;
// case 'b':
// entry.type = 'block';
// break;
// default:
// entry.type = 'unk';
// break;
// }
// if (entry.permissions.acl && entry.rawPath === undefined) { // skip for link targets
// procs.push(useSpawn(['getfacl', '--omit-header', '--no-effective', entry.path], { superuser: 'try' }).promise()
// .then(state => {
// entry.permissions.acl = state.stdout
// .split('\n')
// .filter(line => line && !/^\s*(?:#|$)/.test(line))
// .reduce((acl, line) => {
// const match = line.match(/^([^:]*):([^:]+)?:(.*)$/).slice(1);
// acl[match[0]] = acl[match[0]] ?? {};
// acl[match[0]][match[1] ?? '*'] = {
// r: match[2][0] !== '-',
// w: match[2][1] !== '-',
// x: match[2][2] !== '-',
// }
// return acl;
// }, {});
// })
// .catch(state => {
// console.error(`failed to get ACL for ${entry.path}:`, errorString(state));
// })
// );
// }
// return Promise.all(procs);
// }
// const getAsyncEntryStats = () => {
// const callback = (state, resolver) => {
// state.stdout.trim().split('\n')
// .map(line => {
// try {
// // birth:modification:access
// const [path, ctime, mtime, atime] = line.trim().split(':')
// .map(str => isNaN(Number(str)) ? str : Number(str))
// .map(ts => typeof ts === 'number' ? (ts ? new Date(ts * 1000) : null) : ts);
// return {
// path,
// result: {
// ctime,
// mtime,
// atime,
// }
// }
// } catch (error) {
// console.error(error);
// return {
// path: "",
// result: {
// ctime: null,
// mtime: null,
// atime: null,
// }
// }
// }
// })
// .map(({ path, result: metadata }, index) => {
// let target = entries.value[index];
// if (!target || target.path !== path) {
// console.error(`Had to reverse lookup entry for ${path}, index did not match`);
// target = entries.value.find(entry => entry.path === path);
// }
// if (!target) {
// console.error(`Could not reverse lookup ${path} to assign stats`);
// } else {
// Object.assign(target, metadata)
// }
// });
// resolver();
// }
// return new Promise((resolve, reject) => {
// useSpawn(['stat', '-c', '%n:%W:%Y:%X', '--', ...entries.value.map(({ path }) => path)], { superuser: 'try', err: 'out' }).promise()
// .then(state => callback(state, resolve))
// .catch(state => callback(state, resolve)); // ignore errors to keep list order, err:out for stderr as placeholder
// });
// }
const getEntries = async () => { const getEntries = async () => {
processingHandler.start(); processingHandler.start();
const readLink = (target, cwd, symlinkStr) => { const readLink = (target, cwd, symlinkStr) => {
@ -315,53 +176,6 @@ export default {
} }
}).filter(entry => entry !== null) }).filter(entry => entry !== null)
: []; : [];
// let lsOutput;
// try {
// lsOutput = (await useSpawn(['dir', '-al', '--color=never', '--time-style=full-iso', '--quote-name', '--dereference-command-line-symlink-to-dir', cwd], { superuser: 'try' }).promise()).stdout
// } catch (state) {
// if (state.exit_code === 1)
// lsOutput = state.stdout; // non-fatal ls error
// else
// throw new Error(state.stderr);
// }
// entries.value = lsOutput
// .split('\n')
// .filter(line => !/^(?:\s*$|total)/.test(line)) // remove empty lines
// .map(record => {
// try {
// if (cwd !== props.path)
// return null;
// const entry = reactive({});
// const fields = record.match(/^([a-z-]+\+?)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d+(?:,\s+\d+)?)\s+([^"]+)"([^"]+)"(?:\s+->\s+"([^"]+)")?/)?.slice(1);
// if (!fields) {
// console.error('regex failed to match on', record);
// return null;
// }
// entry.name = fields[6];
// if (entry.name === '.' || entry.name === '..')
// return null;
// entry.path = canonicalPath(cwd + `/${entry.name}`);
// entry.modeStr = fields[0];
// entry.hardlinkCount = parseInt(fields[1]);
// entry.owner = fields[2];
// entry.group = fields[3];
// if (/,/.test(fields[4])) {
// [entry.major, entry.minor] = fields[4].split(/,\s+/);
// entry.size = null;
// } else {
// entry.size = parseInt(fields[4]);
// entry.sizeHuman = cockpit.format_bytes(entry.size, 1000).replace(/(?<!B)$/, ' B');
// entry.major = entry.minor = null;
// }
// procs.push(parseModeStr(cwd, entry, entry.modeStr, fields[7]));
// return entry;
// } catch (error) {
// notifications.value.constructNotification(`Error while gathering info for ${entry.path ?? record}`, errorStringHTML(error), 'error');
// return null;
// }
// })
// .filter(entry => entry !== null)
// ?? [];
processingHandler.start(); processingHandler.start();
console.log("resolving", procs.length, 'symlinks'); console.log("resolving", procs.length, 'symlinks');
return Promise.all(procs) return Promise.all(procs)