-
Notifications
You must be signed in to change notification settings - Fork 141
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
Fix onlyoffice behavior #4138
Merged
Merged
Fix onlyoffice behavior #4138
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8dc9d0f
Use onlyoffice-server in uploadedBy field for OO
nono f916ff7
Open the new version of a document in OO
nono 2e9c596
Make filename more readable for OO conflicts
nono 38ca4aa
Add the /office/keys/:key endpoint
nono 2368a15
Fix OO code from code review feedbacks
nono 95519a2
Fix cozyMetadata.uploaded* fields on upload
nono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package office | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/cozy/cozy-stack/model/instance" | ||
"github.com/cozy/cozy-stack/model/vfs" | ||
) | ||
|
||
// EnsureFileForKey returns the file that will be written when OnlyOffice will | ||
// save a document with the given key. The general case is that is the file | ||
// that has been opened. But, it can also be a new file if a conflict has | ||
// happened because a new version has been uploaded for this file (by the | ||
// desktop client for example). | ||
func EnsureFileForKey(inst *instance.Instance, key string) (*vfs.FileDoc, error) { | ||
detector, err := GetStore().GetDoc(inst, key) | ||
taratatach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return nil, err | ||
} | ||
if detector == nil || detector.ID == "" || detector.Rev == "" { | ||
return nil, ErrInvalidKey | ||
} | ||
|
||
fs := inst.VFS() | ||
file, err := fs.FileByID(detector.ID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if file.Rev() == detector.Rev || bytes.Equal(file.MD5Sum, detector.MD5Sum) { | ||
return file, nil | ||
} | ||
|
||
// Manage the conflict | ||
conflictName := vfs.ConflictName(fs, file.DirID, file.DocName, true) | ||
newfile := vfs.CreateFileDocCopy(file, file.DirID, conflictName) | ||
newfile.CozyMetadata = vfs.NewCozyMetadata(inst.PageURL("/", nil)) | ||
newfile.CozyMetadata.UpdatedAt = newfile.UpdatedAt | ||
newfile.CozyMetadata.UploadedAt = &newfile.UpdatedAt | ||
newfile.CozyMetadata.UploadedBy = &vfs.UploadedByEntry{Slug: OOSlug} | ||
if err := fs.CopyFile(file, newfile); err != nil { | ||
return nil, err | ||
} | ||
|
||
updated := conflictDetector{ID: newfile.ID(), Rev: newfile.Rev(), MD5Sum: newfile.MD5Sum} | ||
_ = GetStore().UpdateSecret(inst, key, file.ID(), newfile.ID()) | ||
_ = GetStore().UpdateDoc(inst, key, updated) | ||
return newfile, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@nono I think we have a problem here. From what I understood, the uploadedBy is only changed when the file is created. So after this route is called, its value always remains at
{"slug": "onlyoffice-server" }
. For the front, it means that the modals are no longer displayed from this point. A more effective way would be to add an entry in updatedByApps and based the front on it. What do you think?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.
In the same way,
CozyMetadata.UploadedAt
should not be modified either. We don't modify these two attributes when uploading a new version via Drive or Desktop.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 do modify these two attributes when a file is uploaded (creation or content modification). It's the stack that does the job. Is it OK for you?
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.
I must have a bug in local, the stack does not modify the fields and it always remains in onlyoffice-server after a modification by OnlyOffice 🙁