Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
icon5.gif   Cleaning up attachments, posted by Louis de Leseleuc on Tue Mar 15 21:38:01 2011 
    icon2.gif   Re: Cleaning up attachments, posted by Stefan Ritt on Fri Mar 18 11:07:50 2011 
       icon2.gif   Re: Cleaning up attachments, posted by Louis de Leseleuc on Mon Mar 21 17:42:15 2011 
Message ID: 67031     Entry time: Mon Mar 21 17:42:15 2011     In reply to: 67028
Icon: Reply  Author: Louis de Leseleuc  Author Email: louis.deleseleuc@nrc-cnrc.gc.ca 
Category: Bug report  OS: Linux  ELOG Version: 2.9.0 
Subject: Re: Cleaning up attachments 

Stefan Ritt wrote:

Louis de Leseleuc wrote:

I noticed a behavior that might be irritating. 

After attaching/uploading files to an entry and before submitting it, one might press 'Back' or close the browser window.

This in effect cancels the entry and sends into oblivion. HOWEVER the attachments and their thumbnail files remain on the server forever.

Would there be a way to either delete attachments after some time if they don't show up in an entry? Or some other magic trick with the browser? My logbook directories are already full of orphan files that I need to seek and destroy.

Also, any thoughts on automatically cleaning up a logbook directory when the damage is done?

Louis

Well, this is not so easy. When you leave the browser (via 'Back' or just by closing), it has no way to communicate with the elog server. I could put in some JavaScript, but if people switch off JavaScript there is no way. On the other hand it might be simple to write just a little shell script, which goes through all files on the server and checks if the file name occurs in some elog entry. This can probably be done with some combination of "find" and  "grep", but I'm not a shell script expert.

How about this:

Whenever a new file is uploaded, it would first be stored in a temporary directory. When the entry gets submitted, the files would be moved to the logbook directory and the entry edited accordingly.

Any wrongfully stored file would remain in that temp dir. Starting/restarting the daemon would cleanup that directory. Seems like a simpler approach and does not involve scripting the browser.

ELOG V3.1.5-fe60aaf