mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 16:40:41 +00:00
fix: Throw an error when readdir is called on a non-directory
This commit is contained in:
@@ -236,6 +236,10 @@ module.exports = class APIError {
|
||||
status: 422,
|
||||
message: 'Directory is not empty.',
|
||||
},
|
||||
'readdir_of_non_directory': {
|
||||
status: 422,
|
||||
message: 'Readdir target must be a directory.',
|
||||
},
|
||||
|
||||
// Write
|
||||
'offset_without_existing_file': {
|
||||
|
||||
@@ -38,7 +38,7 @@ class HLReadDir extends HLFilesystemOperation {
|
||||
if ( ! await svc_acl.check(actor, subject, 'see') ) {
|
||||
throw await svc_acl.get_safe_acl_error(actor, subject, 'see');
|
||||
}
|
||||
return [await subject.getSafeEntry()];
|
||||
throw APIError.create('readdir_of_non_directory');
|
||||
}
|
||||
|
||||
let children;
|
||||
|
||||
@@ -156,6 +156,7 @@ class PosixError extends Error {
|
||||
case 'missing_expected_metadata': return new PosixError(ErrorCodes.EINVAL, e.message);
|
||||
case 'overwrite_and_dedupe_exclusive': return new PosixError(ErrorCodes.EINVAL, e.message);
|
||||
case 'not_empty': return new PosixError(ErrorCodes.ENOTEMPTY, e.message);
|
||||
case 'readdir_of_non_directory': return new PosixError(ErrorCodes.ENOTDIR, e.message);
|
||||
|
||||
// Write
|
||||
case 'offset_without_existing_file': return new PosixError(ErrorCodes.ENOENT, e.message);
|
||||
|
||||
Reference in New Issue
Block a user