-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NC | Multi Protocol Access | List object with conflicting ownership #8751
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,6 +145,7 @@ function _get_filename(file_name) { | |
} | ||
return file_name; | ||
} | ||
|
||
/** | ||
* @param {fs.Dirent} first_entry | ||
* @param {fs.Dirent} second_entry | ||
|
@@ -877,13 +878,7 @@ class NamespaceFS { | |
|
||
const prefix_dir_key = prefix.slice(0, prefix.lastIndexOf('/') + 1); | ||
await process_dir(prefix_dir_key); | ||
await Promise.all(results.map(async r => { | ||
if (r.common_prefix) return; | ||
const entry_path = path.join(this.bucket_path, r.key); | ||
//If entry is outside of bucket, returns stat of symbolic link | ||
const use_lstat = !(await this._is_path_in_bucket_boundaries(fs_context, entry_path)); | ||
r.stat = await nb_native().fs.stat(fs_context, entry_path, { use_lstat }); | ||
})); | ||
await this.validate_results(results, fs_context); | ||
const res = { | ||
objects: [], | ||
common_prefixes: [], | ||
|
@@ -924,6 +919,24 @@ class NamespaceFS { | |
} | ||
} | ||
|
||
async validate_results(results, fs_context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you remove from the list right before it's being returned to the user, you might be left with less than 1000 objects, even if you have access to more than 1000 objects, can you please check that? |
||
await Promise.all(results.map(async r => { | ||
if (r.common_prefix) return; | ||
const entry_path = path.join(this.bucket_path, r.key); | ||
//If entry is outside of bucket, returns stat of symbolic link | ||
const use_lstat = !(await this._is_path_in_bucket_boundaries(fs_context, entry_path)); | ||
try { | ||
r.stat = await nb_native().fs.stat(fs_context, entry_path, { use_lstat }); | ||
} catch (err) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. notice that you throw for all errors and not just EACCES( permission denied) is this intentional? maybe it would be better to create a separate function that doesn't throw for selected errors. like we do in unlink_ignore_enoent. that way we can reuse in case we would like to handle permission issues in other places. see stat for possible error list There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also that way we will be able to handle what happens in case of EACCES outside the catch. something like:
|
||
dbg.warn('NamespaceFS: validate_results : couldnt access file entry_path', entry_path, ", skipping..."); | ||
const index = results.indexOf(r); | ||
if (index > -1) { | ||
results.splice(index, 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about bucket owner, do we always want to remove this entry from the list? this should be compatible to S3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @romayalon When removing an item from the list, there is a chance the list object returns with less than 1000 items One solution would be to check the access while adding the item to result in an array and return 1000 items |
||
} | ||
} | ||
})); | ||
} | ||
|
||
///////////////// | ||
// OBJECT READ // | ||
///////////////// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is a good name for this function. there is no much validation going on here. maybe change it to something like _get_stats_for_list_object. also, in my opinion, if you like to move it to a function it would be better to move the lambda function to a desperate function, instead of the whole Promise.all. WDYT?