-
Notifications
You must be signed in to change notification settings - Fork 44
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
Hotfix/sharing: some more bugs with sharing and mirror file creation #161
Changes from 1 commit
62ef9c1
26a4678
b6c66b9
1742bb0
c12046c
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ type MirrorBucketSchema struct { | |
const mirrorFileModelName = "MirrorFile" | ||
|
||
var errMirrorFileNotFound = errors.New("Mirror file not found") | ||
var errMirrorFileAlreadyExists = errors.New("Mirror file already exists") | ||
|
||
func (m *model) CreateMirrorBucket(ctx context.Context, bucketSlug string, mirrorBucket *MirrorBucketSchema) (*BucketSchema, error) { | ||
metaCtx, metaDbID, err := m.initBucketModel(ctx) | ||
|
@@ -71,12 +72,12 @@ func (m *model) FindMirrorFileByPathAndBucketSlug(ctx context.Context, path, buc | |
} | ||
|
||
if rawMirrorFiles == nil { | ||
return &MirrorFileSchema{}, nil | ||
return nil, nil | ||
} | ||
|
||
mirror_files := rawMirrorFiles.([]*MirrorFileSchema) | ||
if len(mirror_files) == 0 { | ||
return &MirrorFileSchema{}, nil | ||
return nil, nil | ||
} | ||
|
||
log.Debug("Model.FindMirrorFileByPathAndBucketSlug: returning mirror file with dbid " + mirror_files[0].DbID) | ||
|
@@ -89,11 +90,15 @@ func (m *model) CreateMirrorFile(ctx context.Context, mirrorFile *domain.MirrorF | |
return nil, err | ||
} | ||
|
||
_, err = m.FindMirrorFileByPathAndBucketSlug(ctx, mirrorFile.Path, mirrorFile.BucketSlug) | ||
mf, err := m.FindMirrorFileByPathAndBucketSlug(ctx, mirrorFile.Path, mirrorFile.BucketSlug) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if mf != nil { | ||
return nil, errMirrorFileAlreadyExists | ||
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. I wonder: should we return 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. Will leave this as-is for now and can update later since it's working at least. If we need a create or get type usage if this later we can always update. |
||
} | ||
|
||
newInstance := &MirrorFileSchema{ | ||
Path: mirrorFile.Path, | ||
BucketSlug: mirrorFile.BucketSlug, | ||
|
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.
Maybe add a comment on this function that
paths
would be modified. Personally, I think it would have been better if the function returned the modifiedpaths
instead of mutating the input value, but eitherways a comment should help make it more apparent.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.
Fixed in 26a4678.