Changes between Initial Version and Version 1 of Ticket #306


Ignore:
Timestamp:
Aug 11, 2005, 11:26:53 AM (19 years ago)
Author:
Adrian Holovaty
Comment:

(Changed formatting in description)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #306 – Description

    initial v1  
    55datetime stamps, like so:
    66
     7{{{
    78class MusicRoot(meta.Model):
    89    fields = (
     
    1112        meta.DateTimeField('last_scan_finished', blank = True, null = True),
    1213        )
     14}}}
    1315
    1416I also have a track model that has some fields and a "last_scanner"
    1517date time field, like so:
    1618
     19{{{
    1720class Track(meta.Model):
    1821    fields = (
     
    2124        meta.DateTimeField('last_scanned', blank = True, null = True),
    2225        )
     26}}}
    2327
    2428Now, in order to figure out if a "track" file has been removed (and
     
    3236After I am done walking all the files I do this simple operation to
    3337find out which tracks are no longer in this music root:
    34 
    35         missing_tracks = tracks.get_list(last_scanned__lt = \
    36                                          music_root.last_scan_started)
     38{{{
     39        missing_tracks = tracks.get_list(last_scanned__lt = music_root.last_scan_started)
     40}}}
    3741
    3842Now, earlier in the same function I had done:
    3943
     44{{{
    4045        music_root.last_scan_started = datetime.datetime.now()
    4146        music_root.save()
     47}}}
    4248
    4349The problem? "missing_tracks" is _all the tracks_ in the music root.
    4450Pounded my head for a couple of minutes and then realized this:
    4551
    46         music_root.last_scan_started -> 2005-08-10 23:38:49.031080
     52{{{
     53music_root.last_scan_started -> 2005-08-10 23:38:49.031080
     54}}}
    4755
    4856Almost all the tracks, that were filled in via fetches from the db if
     
    5058was in a sub-scope) were:
    5159
    52        track.last_scanned -> 2005-08-10 23:38:49
     60{{{
     61track.last_scanned -> 2005-08-10 23:38:49
     62}}}
    5363
    5464so:
    5565
    56    2005-08-10 23:38:49 < 2005-08-10 23:38:49.031080
     66{{{
     672005-08-10 23:38:49 < 2005-08-10 23:38:49.031080
     68}}}
    5769
    5870I worked around this by doing a:
    5971
    60         music_root = musicroots.get_object(pk = music_root.id)
     72{{{
     73music_root = musicroots.get_object(pk = music_root.id)
     74}}}
    6175
    6276which seems to work although it might not if any funky caching is
     
    6478
    6579But I should not need to do that.
    66 
Back to Top