ralsina / aranduka

Automatically exported from code.google.com/p/aranduka
0 stars 1 forks source link

Deleting book files from file manager doesn't remove it from database #58

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Delete a file from a book
2. Go to about the book view
3. The file is still associated

What is the expected output? What do you see instead?
Shouldn't Aranduka check if the book's files stil exist? and, in case all the 
files associated to a book are deleted, prompt to delete the book from the 
database? or de-associate the deleted files?

Maybe we can check on start-up and re-check on demand with an option on a menu 
entry.

Original issue reported on code.google.com by algoz...@gmail.com on 24 Feb 2011 at 6:01

GoogleCodeExporter commented 9 years ago
You mean if you delete a file manually from the filesystem?

I think doing the sanity check on start-up would be too long if you have a 
large database. It would probably be better to do it whenever you get a list of 
book files.

Original comment by andresgattinoni on 6 Apr 2011 at 2:03

GoogleCodeExporter commented 9 years ago
Yep, that is what I mean.. +1 to check when you get the list of book files. It 
shouldn't take long to check 3 or 4 files.. :-)

Original comment by algoz...@gmail.com on 6 Apr 2011 at 5:49

GoogleCodeExporter commented 9 years ago
What I'm seeing is that in most places where we list files, we use a Book 
object and iterate over its files. I don't know if (and how) we can override 
some method of the File entity so that it does what we want whenever a book's 
files are listed. Any ideas?

Original comment by andresgattinoni on 11 Apr 2011 at 2:28

GoogleCodeExporter commented 9 years ago
I don't quite understand the idea.. Do you mean create/override some method of 
the File entity so it does the sanity checks and return a list of valid files?

Original comment by algoz...@gmail.com on 11 Apr 2011 at 6:13

GoogleCodeExporter commented 9 years ago
Yes, I was thinking something like that. If it's not possible we'll have to 
create an ad hoc method and change the way we access to a Book's files. The 
method wouldn't be hard to code, and probably now there are only a couple of 
places where we would have to change the call... but it would make the code a 
little less intuitive/straight-forward... so I was wondering if there was a way 
to do that more transparently

Original comment by andresgattinoni on 12 Apr 2011 at 5:08

GoogleCodeExporter commented 9 years ago
mm.. what about having a complement method called e.g. "getValidFiles()" that 
returns only the valid files and leave the other method unchanged?

Original comment by algoz...@gmail.com on 12 Apr 2011 at 6:03

GoogleCodeExporter commented 9 years ago
Yes, we could do that... I was just wondering if there would be a way to do it 
more transparently

Original comment by andresgattinoni on 12 Apr 2011 at 11:52

GoogleCodeExporter commented 9 years ago
and what about a adding parameter to the current method like sanitize=True to 
get only the valid file names?

Original comment by algoz...@gmail.com on 13 Apr 2011 at 6:37

GoogleCodeExporter commented 9 years ago
The thing is that the current method is:

book = models.Book.get_by(id=book_id)
for file in book.files:
  ...

My question was, precisely, what method could we override to leave that as it 
is.

Original comment by andresgattinoni on 13 Apr 2011 at 7:45

GoogleCodeExporter commented 9 years ago
I don't know.. I'm out of ideas.. :(

Original comment by algoz...@gmail.com on 20 Apr 2011 at 1:28