fix moving files from external storage to object store trashbin#21628
Merged
MorrisJobke merged 4 commits intomasterfrom Jul 23, 2020
Merged
fix moving files from external storage to object store trashbin#21628MorrisJobke merged 4 commits intomasterfrom
MorrisJobke merged 4 commits intomasterfrom
Conversation
Contributor
|
cc @dragon988 |
|
I'm not using S3 anymore but the code looks good to me. |
rullzer
reviewed
Jun 30, 2020
kesselb
reviewed
Jul 1, 2020
| return (int)file_put_contents($this->getSourcePath($path), $stream); | ||
| $result = file_put_contents($this->getSourcePath($path), $stream); | ||
| if ($result === false) { | ||
| throw new GenericFileException("Failed write steam to $path"); |
kesselb
reviewed
Jul 1, 2020
9fe6afe to
63efe79
Compare
MorrisJobke
reviewed
Jul 6, 2020
MorrisJobke
approved these changes
Jul 6, 2020
Member
MorrisJobke
left a comment
There was a problem hiding this comment.
Code looks good 👍 I refined one exception message to also include the path so that looking at the logs makes more sense later on.
Member
|
PHPUnit fails |
having the "cache rename" after the "storage move" caused the target to get the fileid from the source file, without taking care that the object is stored under the original file id. By doing the "cache rename" first, we trigger the "update existing file" logic while moving the file to the object store and the object gets stored for the correct file id Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
this remove the ambiguity when writing zero length files Signed-off-by: Robin Appelman <robin@icewind.nl>
b5170c2 to
ad7798f
Compare
Signed-off-by: Robin Appelman <robin@icewind.nl>
Member
Author
|
ci fixed |
Member
Author
|
/backport to stable19 |
Member
Author
|
/backport to stable18 |
This was referenced Jul 23, 2020
Member
|
So this breaks deleting files in an object store setup :/ |
Member
{
"reqId": "8eOJATfs8cPyjKQ5j2DI",
"level": 4,
"time": "2020-07-30T12:30:26+00:00",
"remoteAddr": "127.0.0.1",
"user": "admin",
"app": "webdav",
"method": "DELETE",
"url": "/remote.php/dav/files/admin/Bildschirmfoto%202020-07-29%20um%2017.50.40.png",
"message": {
"Exception": "TypeError",
"Message": "Argument 1 passed to OC\\Files\\Cache\\CacheQueryBuilder::whereFileId() must be of the type int, null given, called in /Users/morris/Projects/nextcloud/server/lib/private/Files/Cache/Cache.php on line 661",
"Code": 0,
"Trace": [
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Cache/Cache.php",
"line": 661,
"function": "whereFileId",
"class": "OC\\Files\\Cache\\CacheQueryBuilder",
"type": "->",
"args": [
null
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Cache/Cache.php",
"line": 585,
"function": "moveFromCache",
"class": "OC\\Files\\Cache\\Cache",
"type": "->",
"args": [
{
"__class__": "OC\\Files\\Cache\\Cache"
},
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/ObjectStore/ObjectStoreStorage.php",
"line": 347,
"function": "move",
"class": "OC\\Files\\Cache\\Cache",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Storage/Wrapper/Wrapper.php",
"line": 278,
"function": "rename",
"class": "OC\\Files\\ObjectStore\\ObjectStoreStorage",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Storage/Wrapper/Availability.php",
"line": 295,
"function": "rename",
"class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Storage/Wrapper/Wrapper.php",
"line": 278,
"function": "rename",
"class": "OC\\Files\\Storage\\Wrapper\\Availability",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Storage/Wrapper/Wrapper.php",
"line": 572,
"function": "rename",
"class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/files_trashbin/lib/Trashbin.php",
"line": 288,
"function": "moveFromStorage",
"class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
"type": "->",
"args": [
{
"cache": {
"__class__": "OC\\Files\\Cache\\Cache"
},
"scanner": null,
"watcher": null,
"propagator": {
"__class__": "OC\\Files\\Cache\\Propagator"
},
"updater": {
"__class__": "OC\\Files\\Cache\\Updater"
},
"__class__": "OCA\\Files_Trashbin\\Storage"
},
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"files_trashbin/files/Bildschirmfoto 2020-07-29 um 17.50.40.png.d1596112226"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/files_trashbin/lib/Trash/LegacyTrashBackend.php",
"line": 108,
"function": "move2trash",
"class": "OCA\\Files_Trashbin\\Trashbin",
"type": "::",
"args": [
"Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/files_trashbin/lib/Trash/TrashManager.php",
"line": 103,
"function": "moveToTrash",
"class": "OCA\\Files_Trashbin\\Trash\\LegacyTrashBackend",
"type": "->",
"args": [
{
"cache": {
"__class__": "OC\\Files\\Cache\\Cache"
},
"scanner": null,
"watcher": null,
"propagator": {
"__class__": "OC\\Files\\Cache\\Propagator"
},
"updater": {
"__class__": "OC\\Files\\Cache\\Updater"
},
"__class__": "OCA\\Files_Trashbin\\Storage"
},
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/files_trashbin/lib/Storage.php",
"line": 192,
"function": "moveToTrash",
"class": "OCA\\Files_Trashbin\\Trash\\TrashManager",
"type": "->",
"args": [
{
"cache": {
"__class__": "OC\\Files\\Cache\\Cache"
},
"scanner": null,
"watcher": null,
"propagator": {
"__class__": "OC\\Files\\Cache\\Propagator"
},
"updater": {
"__class__": "OC\\Files\\Cache\\Updater"
},
"__class__": "OCA\\Files_Trashbin\\Storage"
},
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/files_trashbin/lib/Storage.php",
"line": 99,
"function": "doDelete",
"class": "OCA\\Files_Trashbin\\Storage",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png",
"unlink"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/View.php",
"line": 1161,
"function": "unlink",
"class": "OCA\\Files_Trashbin\\Storage",
"type": "->",
"args": [
"files/Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/lib/private/Files/View.php",
"line": 718,
"function": "basicOperation",
"class": "OC\\Files\\View",
"type": "->",
"args": [
"unlink",
"/Bildschirmfoto 2020-07-29 um 17.50.40.png",
[
"delete"
]
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/dav/lib/Connector/Sabre/File.php",
"line": 455,
"function": "unlink",
"class": "OC\\Files\\View",
"type": "->",
"args": [
"/Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/dav/lib/DAV/Tree.php",
"line": 183,
"function": "delete",
"class": "OCA\\DAV\\Connector\\Sabre\\File",
"type": "->",
"args": []
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
"line": 295,
"function": "delete",
"class": "Sabre\\DAV\\Tree",
"type": "->",
"args": [
"files/admin/Bildschirmfoto 2020-07-29 um 17.50.40.png"
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
"line": 89,
"function": "httpDelete",
"class": "Sabre\\DAV\\CorePlugin",
"type": "->",
"args": [
{
"__class__": "Sabre\\HTTP\\Request"
},
{
"__class__": "Sabre\\HTTP\\Response"
}
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/dav/lib/DAV/Server.php",
"line": 474,
"function": "emit",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": [
"method:DELETE",
[
{
"__class__": "Sabre\\HTTP\\Request"
},
{
"__class__": "Sabre\\HTTP\\Response"
}
]
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/dav/lib/DAV/Server.php",
"line": 251,
"function": "invokeMethod",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": [
{
"__class__": "Sabre\\HTTP\\Request"
},
{
"__class__": "Sabre\\HTTP\\Response"
}
]
},
{
"file": "/Users/morris/Projects/nextcloud/server/3rdparty/sabre/dav/lib/DAV/Server.php",
"line": 319,
"function": "start",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": []
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/dav/lib/Server.php",
"line": 325,
"function": "exec",
"class": "Sabre\\DAV\\Server",
"type": "->",
"args": []
},
{
"file": "/Users/morris/Projects/nextcloud/server/apps/dav/appinfo/v2/remote.php",
"line": 35,
"function": "exec",
"class": "OCA\\DAV\\Server",
"type": "->",
"args": []
},
{
"file": "/Users/morris/Projects/nextcloud/server/remote.php",
"line": 167,
"args": [
"/Users/morris/Projects/nextcloud/server/apps/dav/appinfo/v2/remote.php"
],
"function": "require_once"
}
],
"File": "/Users/morris/Projects/nextcloud/server/lib/private/Files/Cache/CacheQueryBuilder.php",
"Line": 66,
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15",
"version": "20.0.0.0"
}The server/lib/private/Files/Cache/Cache.php Line 614 in cb05782 |
Member
This was referenced Aug 1, 2020
Closed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

having the "cache rename" after the "storage move" caused the target
to get the fileid from the source file, without taking care that the object
is stored under the original file id.
By doing the "cache rename" first, we trigger the "update existing file"
logic while moving the file to the object store and the object gets stored for the
correct file id
Signed-off-by: Robin Appelman robin@icewind.nl