Changes between Initial Version and Version 1 of Ticket #306
- Timestamp:
- Aug 11, 2005, 11:26:53 AM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #306 – Description
initial v1 5 5 datetime stamps, like so: 6 6 7 {{{ 7 8 class MusicRoot(meta.Model): 8 9 fields = ( … … 11 12 meta.DateTimeField('last_scan_finished', blank = True, null = True), 12 13 ) 14 }}} 13 15 14 16 I also have a track model that has some fields and a "last_scanner" 15 17 date time field, like so: 16 18 19 {{{ 17 20 class Track(meta.Model): 18 21 fields = ( … … 21 24 meta.DateTimeField('last_scanned', blank = True, null = True), 22 25 ) 26 }}} 23 27 24 28 Now, in order to figure out if a "track" file has been removed (and … … 32 36 After I am done walking all the files I do this simple operation to 33 37 find 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 }}} 37 41 38 42 Now, earlier in the same function I had done: 39 43 44 {{{ 40 45 music_root.last_scan_started = datetime.datetime.now() 41 46 music_root.save() 47 }}} 42 48 43 49 The problem? "missing_tracks" is _all the tracks_ in the music root. 44 50 Pounded my head for a couple of minutes and then realized this: 45 51 46 music_root.last_scan_started -> 2005-08-10 23:38:49.031080 52 {{{ 53 music_root.last_scan_started -> 2005-08-10 23:38:49.031080 54 }}} 47 55 48 56 Almost all the tracks, that were filled in via fetches from the db if … … 50 58 was in a sub-scope) were: 51 59 52 track.last_scanned -> 2005-08-10 23:38:49 60 {{{ 61 track.last_scanned -> 2005-08-10 23:38:49 62 }}} 53 63 54 64 so: 55 65 56 2005-08-10 23:38:49 < 2005-08-10 23:38:49.031080 66 {{{ 67 2005-08-10 23:38:49 < 2005-08-10 23:38:49.031080 68 }}} 57 69 58 70 I worked around this by doing a: 59 71 60 music_root = musicroots.get_object(pk = music_root.id) 72 {{{ 73 music_root = musicroots.get_object(pk = music_root.id) 74 }}} 61 75 62 76 which seems to work although it might not if any funky caching is … … 64 78 65 79 But I should not need to do that. 66