Skip to content

Commit

Permalink
models: Change Track.last_modified from seconds to ms
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Mar 13, 2015
1 parent 980e045 commit 3a61445
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.rst
Expand Up @@ -13,6 +13,12 @@ v0.20.0 (UNRELEASED)
- Add :class:`mopidy.models.Image` model to be returned by
:meth:`mopidy.core.LibraryController.get_images`. (Part of :issue:`973`)

- Change the semantics of :attr:`mopidy.models.Track.last_modified` to be
milliseconds instead of seconds since Unix epoch, or a simple counter,
depending on the source of the track. This makes it match the semantics of
:attr:`mopidy.models.Playlist.last_modified`. (Fixes: :issue:`678`, PR:
:issue:`1036`)

**Core API**

- Deprecate all properties in the core API. The previously undocumented getter
Expand Down
7 changes: 4 additions & 3 deletions mopidy/models.py
Expand Up @@ -378,9 +378,10 @@ class Track(ImmutableObject):
#: The MusicBrainz ID of the track. Read-only.
musicbrainz_id = None

#: Integer representing when the track was last modified, exact meaning
#: depends on source of track. For local files this is the mtime, for other
#: backends it could be a timestamp or simply a version counter.
#: Integer representing when the track was last modified. Exact meaning
#: depends on source of track. For local files this is the modification
#: time in milliseconds since Unix epoch. For other backends it could be an
#: equivalent timestamp or simply a version counter.
last_modified = None

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion mopidy/utils/path.py
Expand Up @@ -200,7 +200,7 @@ def _find(root, thread_count=10, relative=False, follow=False):

def find_mtimes(root, follow=False):
results, errors = _find(root, relative=False, follow=follow)
mtimes = dict((f, int(st.st_mtime)) for f, st in results.items())
mtimes = dict((f, int(st.st_mtime * 1000)) for f, st in results.items())
return mtimes, errors


Expand Down

0 comments on commit 3a61445

Please sign in to comment.