From a4e5a7beee2c59be9c412dddffab43d2cf84ad50 Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Thu, 28 Nov 2024 16:48:14 +0100 Subject: [PATCH] Fix 500 for conflicts when downstreaming a file from NextCloud --- model/nextcloud/nextcloud.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/model/nextcloud/nextcloud.go b/model/nextcloud/nextcloud.go index db2d16e955e..43a8d672b9b 100644 --- a/model/nextcloud/nextcloud.go +++ b/model/nextcloud/nextcloud.go @@ -252,6 +252,14 @@ func (nc *NextCloud) Downstream(path, dirID string, kind OperationKind, cozyMeta doc.CozyMetadata = cozyMetadata fs := nc.inst.VFS() + exists, err := fs.GetIndexer().DirChildExists(doc.DirID, doc.DocName) + if err != nil { + return nil, err + } + if exists { + doc.DocName = vfs.ConflictName(fs, doc.DirID, doc.DocName, true) + } + file, err := fs.CreateFile(doc, nil) if err != nil { return nil, err