diff options
author | Gaël Bonithon <gael@xfce.org> | 2021-12-18 16:06:04 +0100 |
---|---|---|
committer | Gaël Bonithon <gael@xfce.org> | 2021-12-21 12:01:32 +0100 |
commit | a242e1324c7a3d1428e2a8ce58ee77c71967d8b7 (patch) | |
tree | 4b2dc8863594a79bdd06dbabe0d55ee2d4a1d6c7 /tumbler/tumbler-thumbnail.h | |
parent | ad432ab47e1ede51bee08af11daca69a9ca6a216 (diff) | |
download | tumbler-a242e1324c7a3d1428e2a8ce58ee77c71967d8b7.tar.gz |
Use microsecond precision for last modification time
When the file system allows it, this prevents Tumbler from believing
that the original file has not been modified since the last time the
thumbnail was created, when in fact modifications have taken place in
the second that the thumbnail was created.
The time of last modification is stored internally in a `gdouble`, and
written to the PNG thumbnail in `%.6f` format. This complies well with
the Freedesktop specification [1], as the stat command returns this
format when invoked as `stat -c%.6Y file`, although it is likely that
the specification was written with the idea that this value be an
integer.
The extraction of the thumbnail information is done via
`g_ascii_strtod()`, so an integer or less precision is not a problem. As
for a code expecting to find an integer, it is likely to simply ignore
the decimal part, as Tumbler used to do by extracting the information
via `atol()`. It is possible, however, that an error will be found if a
more complete extractor is used, such as `strtol()`.
The changes this causes to the exposed Tumbler APIs should also be
inconsequential, as it is a conversion to a higher type. This should
therefore result in implicit conversions, except perhaps for
`tumbler_file_info_get_mtime()`, if its return value is explicitly
stored in a `gint64`.
[1] https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#CREATION
Fixes #15, see !20 for more details.
Diffstat (limited to 'tumbler/tumbler-thumbnail.h')
-rw-r--r-- | tumbler/tumbler-thumbnail.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tumbler/tumbler-thumbnail.h b/tumbler/tumbler-thumbnail.h index 8279073..b142e48 100644 --- a/tumbler/tumbler-thumbnail.h +++ b/tumbler/tumbler-thumbnail.h @@ -65,15 +65,15 @@ struct _TumblerThumbnailIface GError **error); gboolean (*needs_update) (TumblerThumbnail *thumbnail, const gchar *uri, - guint64 mtime); + gdouble mtime); gboolean (*save_image_data) (TumblerThumbnail *thumbnail, TumblerImageData *data, - guint64 mtime, + gdouble mtime, GCancellable *cancellable, GError **error); gboolean (*save_file) (TumblerThumbnail *thumbnail, GFile *file, - guint64 mtime, + gdouble mtime, GCancellable *cancellable, GError **error); }; @@ -85,15 +85,15 @@ gboolean tumbler_thumbnail_load (TumblerThumbnail GError **error); gboolean tumbler_thumbnail_needs_update (TumblerThumbnail *thumbnail, const gchar *uri, - guint64 mtime); + gdouble mtime); gboolean tumbler_thumbnail_save_image_data (TumblerThumbnail *thumbnail, TumblerImageData *data, - guint64 mtime, + gdouble mtime, GCancellable *cancellable, GError **error); gboolean tumbler_thumbnail_save_file (TumblerThumbnail *thumbnail, GFile *file, - guint64 mtime, + gdouble mtime, GCancellable *cancellable, GError **error); TumblerThumbnailFlavor *tumbler_thumbnail_get_flavor (TumblerThumbnail *thumbnail); |