-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Make filer compatible with s3 when handling /buckets/../.. paths (an entry can be both a file and a directory) #4331
base: master
Are you sure you want to change the base?
Conversation
You have successfully added a new CodeQL configuration |
|
…entry can be both a file and a directory) Signed-off-by: changlin.shi <changlin.shi@ly.com>
5c1a4a7
to
7a1cf15
Compare
at func (entry *Entry) IsDirectoryKeyObject() bool {
return entry.IsDirectory && entry.Attributes != nil && entry.Attributes.Mime != ""
} 我被这段代码误导了,所以现在的逻辑是当 为了能正确的识别一个directory entry 是否是 s3文件,是否可以加个 S3专用的 fs.FileType var FileModeS3 fs.FileMode = 1 << (32 - 14) // 偏移的offset设置为14是为了和 fs 的其他 FileMode 区分开 当一个 entry 已经是 filer directory的时候,通过 |
当一个 entry 已经存在,且 entry.IsDirectory() 为true 的话,那么当该 entry 关联的 url 上传文件后会将 entry的mime 属性更新,默认为application/octor-stream |
Signed-off-by: changlin.shi <changlin.shi@ly.com>
if mime != "" { | ||
e.Mime = mime | ||
} else { | ||
e.Mime = "application/octet-stream" |
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.
this incurs unnecessary storage cost
@@ -309,3 +310,7 @@ func processMetadataBytes(reqHeader http.Header, existing map[string][]byte, rep | |||
|
|||
return | |||
} | |||
|
|||
func IsS3FileEntry(entry *filer_pb.Entry) bool { | |||
return !entry.IsDirectory || (entry.Attributes != nil && entry.Attributes.Mime != "") |
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.
s3 directories has mime as "httpd/unix-directory"
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.
Why is mime of s3 directory set to "httpd/unix-directory"? directory is only a logical concept in s3 api design
Here is to consider how to correctly handle s3 files when entry is both s3 files and directories, because directories do not have mime, and s3 files are generally mime (if not, they need to be set to the default application/octorstream). In this way, when an entry is a directory, we can know whether the entry is a file at the same time through mime.
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.
@kmlebedev any comments about setting the mime of s3 directory to "httpd/unix-directory"?
Signed-off-by: changlin.shi <changlin.shi@ly.com>
What problem are we solving?
Due to filer's mandatory compatibility with the path specification of posix, many files (both object files and logical directories in ceph s3) cannot be migrated from ceph to seaweed.
When migrating these files, a response of 409 (prompt 'existing xxx is a directory' or 'existing xxx is a file') will be generated, which is very frustrating
How are we solving the problem?
Make filer compatible with s3 when handling /buckets/../.. paths (an entry can be both a file and a directory)
How is the PR tested?
Checks