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

pkp/pkp-lib#1709 provide export XML for download #1876

Merged
merged 2 commits into from
Oct 18, 2016

Conversation

bozana
Copy link
Collaborator

@bozana bozana commented Oct 12, 2016

S. i) here: #1709
(This PR considers also other export plugins)

@bozana bozana mentioned this pull request Oct 12, 2016
14 tasks
@bozana
Copy link
Collaborator Author

bozana commented Oct 13, 2016

@asmecher, also here, I did the change, to use TemporaryFileManager. Could you please take a look (the last commit)? THANKS!!!

* @param $filePath string the location of the file to be deleted
* @return boolean returns true if successful
*/
function deleteFileByPath($filePath) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not let the TemporaryFileManager persist the file in the database? Then you could get rid of deleteFileByPath, downloadFileByPath, and even ImportExportPlugin::getExportFileName, and let the TemporaryFileManager handle more of the details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I wasn't sure -- it seemed to me to be to much 'action' to write and read from the database and act like this would be like a file upload (considering those information as at a file upload), because this case is a little bit different -- those exported files are not like file uploads, that are usually treated by this manager -- they just write a content to a file. Do you think it would be better to do so?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe there will be also other cases, that are not file upload and could use this kind of functions...

Copy link
Member

Choose a reason for hiding this comment

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

I agree that persisting to the database isn't useful in this case, but it does permit the TemporaryFileManager to take care of managing the file storage, cleanup, etc. The less we re-implement those concerns the better, I think.

For one-shot cases like this there might be a role for a simpler file manager class, but the extra overhead from persisting to the database is so little that I'm not sure it's worth the extra code.

Copy link
Member

Choose a reason for hiding this comment

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

(I don't love the TemporaryFileManager in general, and I'm now directing your work without much recent experience with it -- so if you think we're going down a rabbit hole, please stop me :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, I'll try then to use the DB and TemporaryFileManager as it is... If I figure out problems I'll tell you... :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm... Somehow I don't feel this is good ;-) -- I have first to create a file (from XML string) in order then to divide it apart, to fit the TemporaryFile structure, to get and save information into the DB, that I don't need at all (newFileName, fileType, fileSize, originalFileName). Thus, maybe then to:

  1. write a new class (ExportFileManager?) that will extend the PrivateFileManager and just add the new base path = '/temp/'. Or to
  2. use just a normal FileManager, giving it the manually constructed path to that temp folder? -- I actually only need that base path from the TemporaryFileManager (and to mark it as a temporary file for the code readers) :-P Everything else what I need is in the FileManager (writeFile, downloadFile, deleteFile -- that's it).
    What do you think? Maybe the *6649* Updated German locale for pkp-lib: grid.xml #2?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, OK, let's back off to option 2. Sorry to put you through all this. I would still like to avoid performing file operations outside of some kind of framework when possible, but it looks like using the TemporaryFileManager is a worse solution.

@bozana bozana force-pushed the 1709fix-downloadXML branch from a87ffda to c389ab6 Compare October 18, 2016 13:20
@bozana
Copy link
Collaborator Author

bozana commented Oct 18, 2016

@asmecher, I now changed the commit above to use just the normal FileManager...

@asmecher asmecher merged commit ab02974 into pkp:master Oct 18, 2016
@asmecher
Copy link
Member

Merged, thanks!

@bozana bozana deleted the 1709fix-downloadXML branch October 20, 2016 10:42
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

Successfully merging this pull request may close these issues.

2 participants