fix: report path for broken files as /-void/

This commit is contained in:
KernelDeimos 2024-11-13 12:11:37 -05:00
parent c53107db67
commit 5725bd8c66
2 changed files with 16 additions and 3 deletions

View File

@ -828,6 +828,10 @@ module.exports = class FSNodeContext {
.obtain('fs.fsentry:path') .obtain('fs.fsentry:path')
.exec(this.uid ?? this.entry.uuid); .exec(this.uid ?? this.entry.uuid);
if ( fsentry.path && fsentry.path.startsWith('/-void/') ) {
fsentry.broken = true;
}
fsentry.dirname = _path.dirname(fsentry.path); fsentry.dirname = _path.dirname(fsentry.path);
fsentry.dirpath = fsentry.dirname; fsentry.dirpath = fsentry.dirname;
fsentry.writable = await this.get('writable'); fsentry.writable = await this.get('writable');
@ -856,8 +860,13 @@ module.exports = class FSNodeContext {
// Use client-friendly IDs for shortcut_to // Use client-friendly IDs for shortcut_to
fsentry.shortcut_to = (res.shortcut_to fsentry.shortcut_to = (res.shortcut_to
? await id2uuid(res.shortcut_to) : undefined); ? await id2uuid(res.shortcut_to) : undefined);
fsentry.shortcut_to_path = (res.shortcut_to try {
? await id2path(res.shortcut_to) : undefined); fsentry.shortcut_to_path = (res.shortcut_to
? await id2path(res.shortcut_to) : undefined);
} catch (e) {
fsentry.shortcut_invalid = true;
fsentry.shortcut_uid = res.shortcut_to;
}
// Add file_request_url // Add file_request_url
if(res.file_request_token && res.file_request_token !== ''){ if(res.file_request_token && res.file_request_token !== ''){

View File

@ -250,7 +250,11 @@ class DatabaseFSEntryService extends AdvancedBase {
info.given('fs.fsentry:uuid').provide('fs.fsentry:path') info.given('fs.fsentry:uuid').provide('fs.fsentry:path')
.addStrategy('mysql', async uuid => { .addStrategy('mysql', async uuid => {
// TODO: move id2path here // TODO: move id2path here
return await id2path(uuid); try {
return await id2path(uuid);
} catch (e) {
return '/-void/' + uuid;
}
}); });
(async () => { (async () => {