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

Renderer cannot render file without versions #283

Open
cvuorinen opened this issue Oct 6, 2015 · 2 comments
Open

Renderer cannot render file without versions #283

cvuorinen opened this issue Oct 6, 2015 · 2 comments

Comments

@cvuorinen
Copy link

We have quite a lot of files so I disabled the OriginalVersionPlugin because we don't want to store each file twice since it requires double the disk space. But then the renderer cannot render them anymore because it requires a version. This is probably by design, but what would be the preferred solution to overcome this?

I was thinking either modify the renderer so it can also render a file without a version (call storage->retrieve instead of storage->retrieveVersion if version is empty), and I also thought about creating a version plugin that only symlinks instead of copies but since the version storing is handled by the Storage class it's not possible to change it from within the plugin.

I can make a PR of the modified renderer if you think it's reasonable solution. Or are there any other ways around this issue?

@pekkis
Copy link
Member

pekkis commented Oct 6, 2015

Hello hello!

Yes, it actually is by design but I don't like that design either because it wastes space. Once the original was a different case from the version, but it too caused problems.

I've been actually pondering the case lately. The correct solution, to my opinion, is to fix the root cause once and for all, which is what I am doing for version 0.15.

This solution is to make the storages store physical files and not caring / knowing about what it is for (original / version). It's just a physical resource. Then you can make 1000 versions of this same physical resource, and no space is wasted. I have no idea why I originally did not think of this - the solution would have worked from the beginning just as well and is much more simple and elegant. Sigh.

The work on 0.15 has been going for a while and it has been stalled for a while. I've been thinking about migration paths and such as this is a terribly major restructuring and one that I really really want to make but I also know that you can't take large projects offline for a year to migrate.

Until the version 0.15 comes out, a custom renderer sounds perfectly reasonable. But because the "actual" solution is in the works, I would keep it internal for yourself. Do share the code, would be interested, though!

@cvuorinen
Copy link
Author

Hmm... Seems we are on v0.10 and the way the file versions are handled in the renderer has changed since then. The way I solved it for now, is I created a new Renderer class that extends the filelib renderer and just changed a few lines of code and then use that instead. Not really ideal, since it will certainly break if we upgrade later but it works for now.

Here are the changes I made:

Changed this line: https://github.com/xi-project/xi-filelib/blob/v0.10.4/library/Xi/Filelib/Renderer/Renderer.php#L85
to this:

if (!empty($version) && !$this->fileOperator->hasVersion($file, $version)) {

And then before this line: https://github.com/xi-project/xi-filelib/blob/v0.10.4/library/Xi/Filelib/Renderer/Renderer.php#L114
added this:

if (empty($version)) {
    return $this->storage->retrieve($file->getResource());
}

I looked around a little bit in the current master and 0.14 branch but it would require a bit more code to handle the empty version everywhere it's passed into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants