-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Initial Implementation of Storager #2
Conversation
storage.go
Outdated
if err == nil { | ||
// The directory exist, we should delete it. | ||
// ref: https://github.com/beyondstorage/specs/blob/master/rfcs/134-write-behavior-consistency.md | ||
_, err = s.client.NewDirectoryURL(path).Delete(ctx) |
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.
We don't need to delete the existing dir and recreate here. We can set the metadata for the existing dir object.
storage.go
Outdated
return meta | ||
} | ||
|
||
func (s *Storage) nextObjectPageByDir(ctx context.Context, page *ObjectPage) error { |
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.
Looks the same with nextObjectPageByPrefix
?
storage.go
Outdated
return nil, err | ||
} | ||
// The directory exist, we should reset the metadata. | ||
_, err = s.client.NewDirectoryURL(path).SetMetadata(ctx, nil) |
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.
Sorry for my inaccurate expression. We don't need to call SetMetadata
here. We can use the metadata returned by GetProperties
like lastModified
to assign the value for o.lastModified
. Like what we did in https://github.com/beyondstorage/go-service-kodo/blob/master/storage.go#L51-L60
o.SetContentType(v) | ||
} | ||
if v := fileOutput.ContentMD5(); len(v) > 0 { | ||
o.SetContentMd5(base64.StdEncoding.EncodeToString(v)) |
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.
ping @Xuanwo I'm not sure whether we need base64 encode here? Similar question in https://github.com/beyondstorage/go-service-azfile/pull/2/files#diff-8127f6766ba5110c7a99d07305f11d18295fcb2cb08dddb105ab7d55898742c7R254.
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.
Yes, our content md5 is based encoded, maybe we need to add description in content_md5
.
This week is our 1st cleanup week, we will resume the work here in the next week: https://forum.beyondstorage.io/t/1st-cleanup-week-for-go-storage/213/12
|
} | ||
|
||
// Since `Create' only initializes the file, we need to call `UploadRange' to write the contents to the file. | ||
_, err = s.client.NewFileURL(path).UploadRange(ctx, 0, body, transactionalMD5) |
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.
What happened if transactionalMD5
is empty?
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 is an optional value, so the null value does not affect the API call.
Most LGTM. |
feat: Initial Implementation of Storager