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

files_versions app has problems if two FS operations happen on the same second #8451

Closed
jvillafanez opened this issue May 5, 2014 · 3 comments

Comments

@jvillafanez
Copy link
Member

Consider the following piece of code:

        $res = $this->fsview->fromTmpFile($file['tmp_name'], $filePath);
        $basenameFilePath = basename($filePath);

        if ($basenameFilePath !== $file['name']) {
            $newFilePath = dirname($filePath) . '/' . $file['name'];
sleep(2);  // line required to work properly
            if ($this->fsview->rename($filePath, $newFilePath)) {
                // force a change
                $this->fsview->touch($newFilePath);
            }
        }
  1. Upload /foo/bar1.
  2. Upload bar2 as version of bar1 (code above). This creates a new version of /foo/bar1 -> files_versions/foo/bar1.vT1 and rename bar1 to bar2, so the version should be renamed too.
    We end with /foo/bar2 and files_versions/foo/bar2.vT1
  3. Upload bar3 as version of bar2 (code above). This creates a new version of /foo/bar2 -> files_versions/foo/bar2.vT2 and rename both the file and the versions of the file.

However, at some point in the 3rd step, the rename of the versions doesn't work and the versions of the file are lost. There won't be any versions of the renamed file.

I've checked the DB that after step 3: there are two versions of /foo/bar2 (created in steps 2 and 3) but no versions of the /foo/bar3. I think the files were renamed correctly in the FS but not in the DB.

My guess is that there might be some issues regarding timestamps. That's why I've added the "sleep(2)" line. This will make sure that the write and rename operation happen in different seconds. After adding this line, the files_versions app works as expected.

@PVince81
Copy link
Contributor

PVince81 commented May 5, 2014

@schiesbn

@schiessle
Copy link
Contributor

The timestamp is based on seconds, so you are right. If a file gets edited multiple times within one second then we will only have the oldest version within the second. But I think that's OK. We don't need to keep more than one version per seconds.

We could add this to the documentation where we describe the different slices: http://doc.owncloud.org/server/6.0/user_manual/files/versioncontrol.html

@schiessle
Copy link
Contributor

The documentation is now updated to reflect the fact that we don't keep more than one version per second

@lock lock bot locked as resolved and limited conversation to collaborators Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants