Skip to content
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

Feature/version metadata #39126

Merged
merged 5 commits into from
Nov 18, 2021
Merged

Feature/version metadata #39126

merged 5 commits into from
Nov 18, 2021

Conversation

pushnov-i
Copy link
Contributor

@pushnov-i pushnov-i commented Aug 20, 2021

The file version author is now being saved in an appropriate timestamp-prefixed JSON file and displayed in the version list on PROPFIND request. Rename, copy and deletion are take into account.

Enable with config-flag: 'file_storage.save_version_author' => true, in config.php

@CLAassistant
Copy link

CLAassistant commented Aug 20, 2021

CLA assistant check
All committers have signed the CLA.

@IljaN
Copy link
Contributor

IljaN commented Aug 20, 2021

  • You can fix codestyle by running: make test-php-style-fix
  • You can run stan and phan (static-analyzers) via: make test-php-phpstan and make test-php-phan

Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments 👍

Some indentations seem to be off, make test-php-style-fix should fix this.

@ownclouders
Copy link
Contributor

💥 Acceptance tests pipeline webUISharingExt1-latest-chrome-mariadb10.2-php7.4 failed. The build has been cancelled.

https://drone.owncloud.com/owncloud/core/31929/162/1

@micbar micbar requested a review from DeepDiver1975 August 20, 2021 16:06
@JammingBen
Copy link
Contributor

JammingBen commented Aug 21, 2021

I'm not sure if we should add getUsername() to the overall file interface. This method is (only?) needed in the MetaFileVersionNode class. Look for example how this is done for getContentDispositionFileName() [1].

You could implement a dedicated interface for the getUsername() method, similar to IProvidesAdditionalHeaders. This has then to be implemented by your MetaFileVersionNode class [2]. Your getUsername() method in MetaFile would look something like:

public function getUsername() {
	if ($this->file instanceof \OCP\Files\IVersionAuthor) {
		return $this->file->getUsername();
	}
	return '';
}

[1] https://github.com/owncloud/core/blob/feature/version-metadata/apps/dav/lib/Meta/MetaFile.php#L116
[2] https://github.com/owncloud/core/blob/feature/version-metadata/lib/private/Files/Meta/MetaFileVersionNode.php#L42

About the failing JS test: As the UI now shows the author in the versions tab, you have to adjust the expected result in the tests: https://github.com/owncloud/core/blob/feature/version-metadata/apps/files_versions/tests/js/versionstabviewSpec.js#L71

Feel free to ask if you need any help with that 🙂

On a side note: I tried it on my local instance, but I only see a { where the author should be:

image

@mrow4a
Copy link
Contributor

mrow4a commented Aug 21, 2021

@hodyroff @pushnov-i what about making it optional in admin settings ? Just not to release new feature and reduce blast radius in case of bugs? It touches core functionality of sync/share.

I am bit worried what happens when one of that version “copy” commands fails in the middle. How consistent is the state?

What about expiring old versions ? Is this also handled (if relevant)?

What about acceptance tests here?

Unit tests covering major classes ?

Tested with encryption?

@pushnov-i
Copy link
Contributor Author

pushnov-i commented Aug 23, 2021

@phil-davis thank you, corrected the changes in the version for the interface.
@JammingBen bug fixed (double json encode and tested locally), also implemented everything via interface and adjusted the tests, the unit tests and js tests pass now new quick action feature prevent the drone from getting a successful build

@mrow4a not sure if this is related to the expiration, only retainVersions and getVersion methods from storage are affected, tests have been adjusted. regarding the optional feature, how it should appear on the frontend?

@IljaN
Copy link
Contributor

IljaN commented Aug 23, 2021

There are 8 version-related unit-tests failing https://drone.owncloud.com/owncloud/core/31947/12/9
Click "Show all Lines" and scroll down to line 249. You can ignore the skipped tests.

You can run them locally by running make test-php-unit

@pushnov-i

This comment has been minimized.

@IljaN IljaN assigned IljaN and pushnov-i and unassigned IljaN Aug 23, 2021
@IljaN IljaN added this to the development milestone Aug 23, 2021
@@ -352,7 +352,7 @@ public function testDeleteVersionsOfFolder() {

// check if versions are in trashbin
$results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/' . $name . '/');
$this->assertCount(1, $results);
$this->assertCount(2, $results);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check additionally for an explicit expected result value in the second element of $result here? Only if you don't need to jump trough too much hoops.

@@ -352,7 +352,7 @@ public function testDeleteVersionsOfFolder() {

// check if versions are in trashbin
$results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/' . $name . '/');
$this->assertCount(1, $results);
$this->assertCount(2, $results);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check additionally for an explicit expected result value in the second element of $result here? Only if you don't need to jump trough too much hoops.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in all following assertions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IljaN I did a check yesterday with xdebug and just checked once again now - for this specific case the trashbin dir contains two files first one is the file version with the timestamp and the second is the JSON file with metadata:

Снимок экрана 2021-08-24 в 12 13 46

Copy link
Contributor

@IljaN IljaN Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the second file was introduced trough your change we should maybe explicitly check for it. Maybe in a additional test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you imply a completely separate test for the trash bin, or just an additional test if the second file is a JSON, has a valid name, and contains metadata within testDeleteVersionsOfFolder?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just an additional test if the second file is a JSON, has a valid name, and contains metadata within testDeleteVersionsOfFolder?

This ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the more the better ;)

@IljaN
Copy link
Contributor

IljaN commented Aug 24, 2021

@pushnov-i Looks good now, good work! 🕺 Just a few small nitpicks left.

@mrow4a
Copy link
Contributor

mrow4a commented Aug 24, 2021

@pushnov-i is there a unit/integration test covering backwards compatibility? How code/ui is behaving if there is no metadata-file ?

@IljaN
Copy link
Contributor

IljaN commented Aug 24, 2021

@mrow4a wrote:
Tested with encryption?

This is also a point we should take in to account as the feature will be used first in an ownCloud instance with encryption.

@phil-davis
Copy link
Contributor

@pushnov-i the CLA assistant still says that you have not "signed" the CLA. Please press the button to do that.

@IljaN
Copy link
Contributor

IljaN commented Aug 24, 2021

@mrow4a @pushnov-i Just checked with @phil-davis. If we merge this all acceptance-tests will be run with encryption (master-key and user-key) as nightly-job. Results will be posted tomorrow by drone in #builds in chat.

@pushnov-i Please use the squash-button in github when merging to clean-up the commit history.

@phil-davis
Copy link
Contributor

I don't see any changelog. Did I miss it?

@pushnov-i
Copy link
Contributor Author

@phil-davis added changelog, fixed space.
@IljaN I did not check the encryption since this requires installing an additional plugin, but if only the content of the files will be encrypted, this feature should not affect the workflow as long as the structure of the files within storage won't be changed. I did not manage to add additional tests yet... @mrow4a, if a JSON file is missing, no author will be shown on the UI side. On the code's side, within the storage, you can see that there are conditional checks everywhere, so if the JSON file is present, it will be considered, otherwise ignored.

@phil-davis
Copy link
Contributor

@pushnov-i please click the link to sign the CLA at #39126 (comment)

Does it not work for you? Or?

@pushnov-i
Copy link
Contributor Author

@pushnov-i please click the link to sign the CLA at #39126 (comment)

Does it not work for you? Or?

@phil-davis CLA requires me to change the author of one merge commit since it does not recognize it in github, working on it

@pushnov-i pushnov-i force-pushed the feature/version-metadata branch from 4247c57 to a0f7f5a Compare August 24, 2021 15:54
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

63.2% 63.2% Coverage
0.0% 0.0% Duplication

@pmaier1
Copy link
Contributor

pmaier1 commented Nov 17, 2021

The requirements need to be defined.

The requirement is to see the user who created a version (or: the user who uploaded/saved this state of a file) as part of the version metadata. Basically this enhancement shall allow to "check the last version that Peter created" or "roll back to the state before Peter started working on it".

Here's the original input https://github.com/owncloud/enterprise/issues/4518.

@phil-davis
Copy link
Contributor

Good - now I think that I understand the requirement, and it seems a perfectly reasonable item of metadata about a file (and versions of a file).

The technical thing that I don't think has been implemented in this PR so far is that "the system" needs to know who "created" the current "version" of a file (i.e. the live current data in the file, that is not yet in the version history). That meta-data needs to be stored. For example, if Alice shares a folder with Brian, and Brian uploads "file.txt" into the shared folder, then "the system" needs to remember that the file "creator" is Brian.

Then the rest of the logic is simple - When someone changes the file, the code that moves the "now old" data to the version history has to also move the meta-data also to the version history. Then the new file data is written along with new meta-data about who just "created" the now-latest live "version" of the file.

@IljaN
Copy link
Contributor

IljaN commented Nov 17, 2021

The technical thing that I don't think has been implemented in this PR so far is that "the system" needs to know who "created" the current "version" of a file

AFAIR this requirement was removed in a subsequent call => Creator can be checked via activity app. Will clarify with @pmaier1 now.

If we need to show the creator than this would mean that we will need to show the very first version of a file in the versions view which we don't do yet.

@phil-davis
Copy link
Contributor

We don't have to show the "creator" of the "current version" of a file (the "version" that is not shown in the version history, because it is not yet history!) But technically, IMO, we will have to remember it somewhere so that it is available if and when that data becomes an "old version".

At the moment, if

  1. Alice creates a file
  2. Brian edits it
  3. Carol edits it

At step (2) it is Brian who is authenticated. I don't think "the system" has any way to reliably know that the original file was created by Alice.

At step (3) it is Carol who is authenticated. I don't think "the system" has any way to reliably know that the file before the edit was uploaded by Brian.

@IljaN
Copy link
Contributor

IljaN commented Nov 17, 2021

Maybe we can create a specially-named metadata-file which is not returned by the webdav-api but is internally replaced as soon as a new version is available.

@IljaN
Copy link
Contributor

IljaN commented Nov 17, 2021

Maybe we can create a specially-named metadata-file which is not returned by the webdav-api but is internally replaced as soon as a new version is available.

After talk with @pmaier1 Will implement something like this

@phil-davis
Copy link
Contributor

I raised an issue to make some acceptance tests for this. We can do that in parallel in a branch on top of this.

Note my comment #39504 (comment)

Currently for this feature there is no way for end-users to find out who is the author of the data in the current file. If I was user "Alice" looking at a file, and seeing the author of each old version in the version history, an thinking about restoring some version, then probably I am doing it because the current data in the file is "wrong/corrupt" in some way. So I will immediately want to know "who is the author of the current data in the file?"

As Alice I can already find out other meta-data about the current file - modified date, tags, comments. Should users be able to find out the "latest author"?

@IljaN
Copy link
Contributor

IljaN commented Nov 18, 2021

Possible edge-case: As of now we don't write versions for empty files (filesize=0): So we also shouldn't write metadata for emtpy files. (?)

@phil-davis
Copy link
Contributor

Possible edge-case: As of now we don't write versions for empty files (filesize=0): So we also shouldn't write metadata for emtpy files. (?)

And a combination edge-case. If we add some way for users to find out the "author" of the current file, then if there is version history of non-empty versions of the file, and "someone" has uploaded an empty file as the current file, then I think that user Alice will want to know who uploaded the "nothing" to the file.

Copy link

@AlexAndBear AlexAndBear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for now - Still in Beta Phase - Will be ready before RC

@AlexAndBear AlexAndBear dismissed DeepDiver1975’s stale review November 18, 2021 10:57

Approving for now - Still in Beta Phase - Will be ready before RC

@AlexAndBear AlexAndBear merged commit 49110b5 into master Nov 18, 2021
@delete-merged-branch delete-merged-branch bot deleted the feature/version-metadata branch November 18, 2021 10:59
@mmattel
Copy link
Contributor

mmattel commented Nov 18, 2021

@janackermann docs relevant 👋, pls file a docs issue.

phil-davis pushed a commit that referenced this pull request Nov 18, 2021
Co-authored-by: Ilia Pushnov <[email protected]>
@IljaN IljaN mentioned this pull request Nov 22, 2021
11 tasks
@IljaN
Copy link
Contributor

IljaN commented Nov 22, 2021

Continued here: #39516

phil-davis pushed a commit that referenced this pull request Nov 25, 2021
Co-authored-by: Ilia Pushnov <[email protected]>
@JammingBen JammingBen added php Pull requests that update Php code and removed 3 - To Review labels Nov 25, 2021
phil-davis pushed a commit that referenced this pull request Dec 1, 2021
Co-authored-by: Ilia Pushnov <[email protected]>
IljaN pushed a commit that referenced this pull request Dec 5, 2021
Co-authored-by: Ilia Pushnov <[email protected]>
phil-davis pushed a commit that referenced this pull request Dec 6, 2021
Co-authored-by: Ilia Pushnov <[email protected]>
@jnweiger
Copy link
Contributor

jnweiger commented Dec 8, 2021

tested in 10.9.0 beta1

  • works fine with and without encryption.
  • delete restore should be improved -> 39571

@phil-davis
Copy link
Contributor

Note: I am quite sure that the version authors are off-by-one in 10.9.0 beta1. That is being fixed in #39516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.