Skip to content

Commit

Permalink
fix: report path for broken files as /-void/
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Nov 13, 2024
1 parent c53107d commit 5725bd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/backend/src/filesystem/FSNodeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ module.exports = class FSNodeContext {
.with('fs.fsentry:uuid')
.obtain('fs.fsentry:path')
.exec(this.uid ?? this.entry.uuid);

if ( fsentry.path && fsentry.path.startsWith('/-void/') ) {
fsentry.broken = true;
}

fsentry.dirname = _path.dirname(fsentry.path);
fsentry.dirpath = fsentry.dirname;
Expand Down Expand Up @@ -856,8 +860,13 @@ module.exports = class FSNodeContext {
// Use client-friendly IDs for shortcut_to
fsentry.shortcut_to = (res.shortcut_to
? await id2uuid(res.shortcut_to) : undefined);
fsentry.shortcut_to_path = (res.shortcut_to
? await id2path(res.shortcut_to) : undefined);
try {
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
if(res.file_request_token && res.file_request_token !== ''){
Expand Down
6 changes: 5 additions & 1 deletion src/backend/src/filesystem/storage/DatabaseFSEntryService.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ class DatabaseFSEntryService extends AdvancedBase {
info.given('fs.fsentry:uuid').provide('fs.fsentry:path')
.addStrategy('mysql', async uuid => {
// TODO: move id2path here
return await id2path(uuid);
try {
return await id2path(uuid);
} catch (e) {
return '/-void/' + uuid;
}
});

(async () => {
Expand Down

0 comments on commit 5725bd8

Please sign in to comment.