Providing --path option to transfer-ownership#27343
Providing --path option to transfer-ownership#27343PVince81 merged 2 commits intoowncloud:masterfrom
Conversation
|
@sharidas, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @PVince81 and @chagrawil to be potential reviewers. |
There was a problem hiding this comment.
s/copy/transfer/ (it's a move, not a copy)
There was a problem hiding this comment.
Replaced copy with transfer in the new update.
There was a problem hiding this comment.
missing double quotes on string ?
There was a problem hiding this comment.
Fixed the double quotes on string in the new update.
d5eb4ce to
d0b7dfb
Compare
8531de1 to
3440a1f
Compare
|
The updated version of the patch is ready for review. @PVince81 Can you please review this change. |
Expected result: folder "transferthis" is no more in "user1"'s account and is present in "user2's" account. Please have a look. |
|
you might need to debug into |
|
@PVince81 Thanks for the feedback. I will have a look at it. |
|
Best would be to write an integration test right away because setting this up for testing is time consuming as you need to start from scratch after a transfer. Running the test when debugging would help save this time. |
cde6634 to
8a62eb7
Compare
|
@sharidas it seems you have found a bug deep in the FS code. In the old code, the move operation would do: But now with the new logic the rename is: Still, it seems the @sharidas for you the fix is to call The View but will need to be fixed separately, I'll make a ticket for it. |
|
Raised View issue here: #27376 |
04f7dd1 to
f388285
Compare
|
@PVince81 I have updated the PR by adding $view->mkdir at https://github.com/owncloud/core/pull/27343/files#diff-0674cc8bda871e32d63705af16fa8144R258. I have verified that share folders and other folders which are created by user1 do get transferred. |
9c2b4d3 to
339e546
Compare
There was a problem hiding this comment.
This sentence is not clear.
Something like this seems better:
When transfering ownership of path "test" from "user0" to "user1"
Also I recommend to put the starting slash before any paths as it is the decided choice to name paths in scenarios.
339e546 to
ed8523a
Compare
|
@SergioBertolinSG I have updated the integration tests. Kindly review the same. |
There was a problem hiding this comment.
The occ command is expecting a --path=$PATH. So this is failing because the lack of '='.
Also the occ command example is wrong because it is not adding the '='.
Usage:
files:transfer-ownership [options] [--] <source-user> <destination-user>
Arguments:
source-user owner of files which shall be moved
destination-user user who will be the new owner of the files
Options:
--path=PATH selectively provide the path to transfer. For example --path "alice/files/Music"
|
Tests passed locally. But this explanation in the help of the command is wrong: Options: Which this changes It has to be: Or change it to use '=' with the command. |
ed044bd to
2c691dd
Compare
|
@PVince81 @SergioBertolinSG I have made the changes. Kindly review them. |
|
Seems to have trouble with PHP 5.6 ? I did run 'make clean |
There was a problem hiding this comment.
the example is wrong, it should not contain the "$userId/files/" piece
There was a problem hiding this comment.
is this safe ? what if there are two directories within the same path, like "somedir/test/somedir" ?
Can you add a PHP comment to explain why you are using strpos here ?
Would also be good to add an explicit condition like >= 0
There was a problem hiding this comment.
Argh, no. Don't do anything with the direct FS. There are some storages that do not store anything in the "data" folder but store in object store.
Please always use the $view methods for checking path existence. $view->is_dir($this->inputPath).
In general in OC never ever access the FS directly, always use a $view or the files public API.
2c691dd to
0886c50
Compare
|
@PVince81 Kindly review my updated PR. I have removed ugly changes which directly access FS. Used $view->is_dir in the updated PR. I have also modified the example 'selectively provide the path to transfer. For example --path "folder_name" or --path="folder_name'. |
There was a problem hiding this comment.
--path "folder_name" or --path="folder_name" ? it's twice the same
PVince81
left a comment
There was a problem hiding this comment.
Almost there!
A few more required changes, especially the one about init mount points.
There was a problem hiding this comment.
add a space after ":" for better readability
There was a problem hiding this comment.
I suggest you use ltrim($this->inputPath, '/') to avoid doubling slashes in case the user input a leading slash in the path
There was a problem hiding this comment.
Before you can use the view you need to first call initMountPoints which is done a bit later.
I suggest you move this validation after the initMountPoints call below, or at least the one from the source user.
The reason for this is that sometimes the storage is not directly on FS but in an object store. Only if the object store is mounted for that user will you be able to access it with the View.
There was a problem hiding this comment.
ah yes, when comparing paths you really need to make sure there are no double slashes.
this makes the ltrim($path, '/') call I suggested above really necessary.
0886c50 to
a42b2af
Compare
|
@PVince81 I have moved the validation part for the path under the initMount. Have provided ltrim for the path ( i.e, $this->inputPath ) and during the path comparison I have used ltrim both in the left hand side and right hand side of the comparison. I have added leading space for $unknownDir ( around the ). I have removed --path="folder_name" in the help. All these are made in the updated commit. |
|
Integration tests fail, see https://jenkins.owncloud.org/job/owncloud-core/job/core/job/PR-27343/15/display/redirect |
|
This behaviour should not be this way: it looks like path value is optional, that's misleading. It should look like --path=PATH Also when running the command without --help it should show the same [--path=PATH] In this case: |
e630a80 to
6008bce
Compare
There was a problem hiding this comment.
ltrim($this->inputPath,'/') to remove leading slashes
There was a problem hiding this comment.
you don't need to ltrim the input path if you do it right at the start
There was a problem hiding this comment.
the reason I'm asking you to ltrim the path is that if someone sets --path=/somedir, this concatenation here would result in "$userId/files//somedir" (double slash)
This will help user to selectively move the folders specified using --path option, instead of moving entire folder under files directory. Signed-off-by: Sujith H <sharidasan@owncloud.com>
Update the integration test for transfer-ownership as the new option --path is introduced in the command. Signed-off-by: Sujith H <sharidasan@owncloud.com>
6008bce to
ed2be64
Compare
|
👍 if tests still pass |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This will help user to selectively move the folders
specified using --path option, instead of moving
entire folder under files directory.
Signed-off-by: Sujith H sharidasan@owncloud.com
Description
The change has been made for occ command's transfer-ownership. An additional --path argument has been added to support. This will help user to pass particular folder/file to move to destination user/target. So I have introduced an optional argument --path. I have deliberately made it optional, as its user choice to move entire folder under files or selectively.
Related Issue
This issue which this patch addresses is https://github.com/owncloud/platform/issues/91
Motivation and Context
This helps the user to selectively transfer the ownership of the files/folders instead of moving entire folder under files.
How Has This Been Tested?
Below is the way I have tested:
The folder files/1/1a/1aa/ has 1aaa, 1aab and 1aac folders
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud# sudo -u www-data ./occ files:transfer-ownership --path "test1/files/1/1a/1aa" test1 test2
Analysing files of test1 ...
0 [>---------------------------]
Collecting all share information for files and folder of test1 ...
0 [>---------------------------]
Transferring files to test2/files/transferred from test1 on 20170309_101206 ...
Restoring shares ...
0 [>---------------------------]
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud#
after the execution I was able to see in test2 user:
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud# ls -lt data/test2/files/transferred\ from\ test1\ on\ 20170309_101206/
total 12
drwxr-xr-x 2 www-data www-data 4096 Mar 9 15:42 1aac
drwxr-xr-x 2 www-data www-data 4096 Mar 9 15:42 1aab
drwxr-xr-x 2 www-data www-data 4096 Mar 9 15:42 1aaa
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud#
and in test1 user:
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud# ls data/test1/files/1/1a/
1ab
root@silburyadmin-Inspiron-5567:/home/sujith/test/owncloud#
Screenshots (if appropriate):
Types of changes
Checklist: