EncFS enable retrieving and updating self (null paths)
This commit is contained in:
parent
7c0e1bfbcf
commit
3821cef116
@ -116,13 +116,13 @@ export function TplFS(client, parent, desc) {
|
|||||||
|
|
||||||
this.update = async (path, data) => {
|
this.update = async (path, data) => {
|
||||||
if((typeof path === 'string') || (path instanceof String)) path = path.split('/');
|
if((typeof path === 'string') || (path instanceof String)) path = path.split('/');
|
||||||
if(path.length > 0) return await (await this.open(path)).update([], data);
|
if((path) && (path.length > 0)) return await (await this.open(path)).update([], data);
|
||||||
else return await this.raw_update(data);
|
else return await this.raw_update(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.cat = async (path=[]) => {
|
this.cat = async (path) => {
|
||||||
if((typeof path === 'string') || (path instanceof String)) path = path.split('/');
|
if((typeof path === 'string') || (path instanceof String)) path = path.split('/');
|
||||||
if(path.length > 0) return await (await this.open(path)).raw_cat();
|
if((path) && (path.length > 0)) return await (await this.open(path)).raw_cat();
|
||||||
else return await this.raw_cat();
|
else return await this.raw_cat();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -279,13 +279,17 @@ EncFS.fromPassword = async function(fs, password) {
|
|||||||
return String.fromCharCode.apply(null, new Uint8Array(res));
|
return String.fromCharCode.apply(null, new Uint8Array(res));
|
||||||
}
|
}
|
||||||
async function path_encrypt(data) {
|
async function path_encrypt(data) {
|
||||||
if((data) && (data.constructor === Array)) return await Promise.all(data.map(x => path_component_encrypt(x)));
|
if(data) {
|
||||||
else return (await Promise.all(data.split('/').map(x => path_component_encrypt(x)))).join('/');
|
if(data.constructor === Array) return await Promise.all(data.map(x => path_component_encrypt(x)));
|
||||||
|
else return (await Promise.all(data.split('/').map(x => path_component_encrypt(x)))).join('/');
|
||||||
|
} else return data;
|
||||||
}
|
}
|
||||||
async function path_decrypt(data) {
|
async function path_decrypt(data) {
|
||||||
if((data) && (data.constructor === Array)) return await Promise.all(data.map(x => path_component_decrypt(x)));
|
if(data) {
|
||||||
else if(data.startsWith('/')) return '/' + await path_decrypt(data.replace(/^\/+/g, ''));
|
if(data.constructor === Array) return await Promise.all(data.map(x => path_component_decrypt(x)));
|
||||||
else return (await Promise.all(data.split('/').map(x => path_component_decrypt(x)))).join('/');
|
else if(data.startsWith('/')) return '/' + await path_decrypt(data.replace(/^\/+/g, ''));
|
||||||
|
else return (await Promise.all(data.split('/').map(x => path_component_decrypt(x)))).join('/');
|
||||||
|
} else return data;
|
||||||
}
|
}
|
||||||
return new EncFS((await fs.mkdir('ZZZE ' + uint8array_to_b64(new Uint8Array(await digest('SHA-1', password))))).chroot(), data_encrypt, data_decrypt, path_encrypt, path_decrypt);
|
return new EncFS((await fs.mkdir('ZZZE ' + uint8array_to_b64(new Uint8Array(await digest('SHA-1', password))))).chroot(), data_encrypt, data_decrypt, path_encrypt, path_decrypt);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user