[gnome-documents] loader: load the original file mtime before the cache one
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] loader: load the original file mtime before the cache one
- Date: Tue, 25 Oct 2011 20:22:34 +0000 (UTC)
commit df0107c88fec1d38f34ab9ffc9e2806926af7306
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Oct 25 16:19:53 2011 -0400
loader: load the original file mtime before the cache one
Otherwise in case we have no cache for a file (e.g. when we're loading
it for the first time) we would set an invalid mtime on the cached copy.
src/lib/gd-pdf-loader.c | 75 ++++++++++++++++++++++++-----------------------
1 files changed, 38 insertions(+), 37 deletions(-)
---
diff --git a/src/lib/gd-pdf-loader.c b/src/lib/gd-pdf-loader.c
index 81ea72f..966ffde 100644
--- a/src/lib/gd-pdf-loader.c
+++ b/src/lib/gd-pdf-loader.c
@@ -491,80 +491,64 @@ pdf_load_job_openoffice_refresh_cache (PdfLoadJob *job)
}
static void
-openoffice_cache_query_info_original_ready_cb (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
+openoffice_cache_query_info_ready_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
{
PdfLoadJob *job = user_data;
GError *error = NULL;
GFileInfo *info;
- guint64 mtime;
info = g_file_query_info_finish (G_FILE (source), res, &error);
if (error != NULL) {
- /* try to create the cache anyway - if the source file
- * is really not readable we'll fail again soon.
- */
+ /* create/invalidate cache */
pdf_load_job_openoffice_refresh_cache (job);
g_error_free (error);
return;
}
- job->original_file_mtime = mtime =
- g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
- g_object_unref (info);
+ job->pdf_cache_mtime =
+ g_file_info_get_attribute_uint64 (info,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED);
- if (mtime > job->pdf_cache_mtime)
+ if (job->original_file_mtime > job->pdf_cache_mtime)
pdf_load_job_openoffice_refresh_cache (job);
else
/* load the cached file */
pdf_load_job_from_pdf (job);
+
+ g_object_unref (info);
}
static void
-openoffice_cache_query_info_ready_cb (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
+openoffice_cache_query_info_original_ready_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data)
{
PdfLoadJob *job = user_data;
GError *error = NULL;
GFileInfo *info;
- GFile *original_file;
+ guint64 mtime;
+ gchar *pdf_path, *tmp_name, *tmp_path;
+ GFile *cache_file;
info = g_file_query_info_finish (G_FILE (source), res, &error);
if (error != NULL) {
- /* create/invalidate cache */
+ /* try to create the cache anyway - if the source file
+ * is really not readable we'll fail again soon.
+ */
pdf_load_job_openoffice_refresh_cache (job);
g_error_free (error);
return;
}
- job->pdf_cache_mtime =
- g_file_info_get_attribute_uint64 (info,
- G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
- original_file = g_file_new_for_uri (job->uri);
- g_file_query_info_async (original_file,
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- job->cancellable,
- openoffice_cache_query_info_original_ready_cb,
- job);
-
- g_object_unref (original_file);
+ job->original_file_mtime = mtime =
+ g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
g_object_unref (info);
-}
-
-static void
-pdf_load_job_from_openoffice (PdfLoadJob *job)
-{
- gchar *pdf_path, *tmp_name, *tmp_path;
- GFile *cache_file;
tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (job->uri));
tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL);
@@ -588,6 +572,23 @@ pdf_load_job_from_openoffice (PdfLoadJob *job)
}
static void
+pdf_load_job_from_openoffice (PdfLoadJob *job)
+{
+ GFile *original_file;
+
+ original_file = g_file_new_for_uri (job->uri);
+ g_file_query_info_async (original_file,
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ job->cancellable,
+ openoffice_cache_query_info_original_ready_cb,
+ job);
+
+ g_object_unref (original_file);
+}
+
+static void
query_info_ready_cb (GObject *obj,
GAsyncResult *res,
gpointer user_data)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]