#5707 BLOC Update.: Previews are not deleted when their matching datastore objects are removed

Zarro Boogs per Child bugtracker at laptop.org
Wed Jan 2 11:21:23 EST 2008


#5707: Previews are not deleted when their matching datastore objects are removed
------------------------+---------------------------------------------------
  Reporter:  Phil       |       Owner:  tomeu    
      Type:  defect     |      Status:  new      
  Priority:  blocker    |   Milestone:  Update.1 
 Component:  datastore  |     Version:  Build 650
Resolution:             |    Keywords:           
  Verified:  0          |    Blocking:           
 Blockedby:             |  
------------------------+---------------------------------------------------

Comment(by tomeu):

 Hi Phil, you can ask the datastore if an object with that uid is there in
 this way:

 {{{
 diff --git a/purge-previews b/purge-previews
 index edbb90c..64a7e59 100755
 --- a/purge-previews
 +++ b/purge-previews
 @@ -35,6 +35,8 @@ import os
  import os.path
  import sys

 +from sugar.datastore import datastore
 +
  # Note that DATASTORE_PATH should almost certainly not be hardcoded, but
 as
  # no one Sugar-related was available at the time of coding this, I'm
 running
  # with it.  Improvements welcome.
 @@ -129,8 +131,9 @@ def purge_previews(datastore, pretend, verbose):
           sys.stdout.write("Handling preview file: %s\n" % preview_file)

        # Check to see if it has a partner-in-crime in the datastore.
 -      potential_datastore_file = os.path.join(datastore_dir,
 preview_file)
 -      if os.path.isfile(potential_datastore_file):
 +      uid = preview_file  # Preview files are named following the uid of
 the object.
 +      objects, count = datastore.find({'uid': uid})
 +      if count == 1:
           if verbose:
              sys.stdout.write("   It has a matching datastore file;
 skipping.\n")
           continue

 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/5707#comment:4>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list