Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

feat: Implement CreateLink and setup linker test in go-service-oss #48

Merged
merged 4 commits into from
Aug 4, 2021

Conversation

abyss-w
Copy link
Contributor

@abyss-w abyss-w commented Aug 3, 2021

feat: Implement CreateLink and setup linker test in go-service-oss

storage.go Outdated
o = s.newObject(true)
o.ID = rp
o.Path = path
o.SetLinkTarget("/" + rt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add / here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I tested it, I found that each time the target was missing a / compared to the expect target.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I tested it, I found that each time the target was missing a / compared to the expect target.

It's not the root cause.

Object storage services like oss, s3 will not have absolute paths like fs. So we need to convert between internal object key and paths that exposed to users.

o.Mode |= ModeLink

// oss `symlink` supports `overwrite`, so we don't need to check if path exists.
err = s.bucket.PutSymlink(rp, rt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to call API first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

storage.go Outdated
o = s.newObject(true)
o.ID = rp
o.Path = path
o.SetLinkTarget("/" + rt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I tested it, I found that each time the target was missing a / compared to the expect target.

It's not the root cause.

Object storage services like oss, s3 will not have absolute paths like fs. So we need to convert between internal object key and paths that exposed to users.

@JinnyYi
Copy link
Contributor

JinnyYi commented Aug 3, 2021

Do we need to check whether the object is symlink in List? Or add the check later?

@abyss-w
Copy link
Contributor Author

abyss-w commented Aug 4, 2021

Do we need to check whether the object is symlink in List? Or add the check later?

I think both are fine. If we need to check if the objects in the list are symlink, then we need to add ListMode support for symlink to go-storage first.

@JinnyYi
Copy link
Contributor

JinnyYi commented Aug 4, 2021

If we need to check if the objects in the list are symlink, then we need to add ListMode support for symlink to go-storage first.

I think there's no need to add ListMode for symlink.

We can get the object type form the response of ListObjects. We just need to set the object mode to ModeLink if the type is Symlink.

get-type

utils.go Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants