Skip to content

Commit

Permalink
Fix a regression when sharing a single file (#4292)
Browse files Browse the repository at this point in the history
The regression was introduced by

0a22f21

When a single file is shared, the call to notify the end of the initial
replication tries to create a sharing directory, which creates a CouchDB
conflict. The fix is just checking that case to avoid creating the
directory.
  • Loading branch information
nono authored Jan 15, 2024
2 parents b494654 + 804f584 commit d88b394
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions model/sharing/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ func (s *Sharing) GetSharingDir(inst *instance.Instance) (*vfs.DirDoc, error) {
fs := inst.VFS()
rule := s.FirstFilesRule()
if rule != nil {
if rule.Mime != "" {
inst.Logger().WithNamespace("sharing").
Warnf("GetSharingDir called for only one file: %s", s.SID)
return nil, ErrInternalServerError
}
dir, _ := fs.DirByID(rule.Values[0])
if dir != nil {
return dir, nil
Expand Down
2 changes: 1 addition & 1 deletion model/sharing/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ func (s *Sharing) EndInitial(inst *instance.Instance) error {
M: map[string]interface{}{"_id": s.SID},
}
realtime.GetHub().Publish(inst, realtime.EventDelete, &doc, nil)
if s.FirstFilesRule() != nil {
if rule := s.FirstFilesRule(); rule != nil && rule.Mime == "" {
if _, err := s.GetSharingDir(inst); err != nil {
return err
}
Expand Down

0 comments on commit d88b394

Please sign in to comment.