[gnome-software] trivial: Allow creating an empty cache dir
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Allow creating an empty cache dir
- Date: Thu, 13 Jul 2017 18:18:48 +0000 (UTC)
commit ae0f7c6dbfc54bb8aeeed9a3f3733ddc98ab1337
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 13 10:45:35 2017 +0100
trivial: Allow creating an empty cache dir
lib/gs-utils.c | 5 +++++
lib/gs-utils.h | 7 ++++---
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index 0e051e3..be79b67 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -203,6 +203,11 @@ gs_utils_get_cache_filename (const gchar *kind,
kind,
NULL);
cachedir_file = g_file_new_for_path (cachedir);
+ if (g_file_query_exists (cachedir_file, NULL) &&
+ flags & GS_UTILS_CACHE_FLAG_ENSURE_EMPTY) {
+ if (!gs_utils_rmtree (cachedir, error))
+ return FALSE;
+ }
if (!g_file_query_exists (cachedir_file, NULL) &&
!g_file_make_directory_with_parents (cachedir_file, NULL, error))
return NULL;
diff --git a/lib/gs-utils.h b/lib/gs-utils.h
index 17a0731..7d8cdab 100644
--- a/lib/gs-utils.h
+++ b/lib/gs-utils.h
@@ -37,9 +37,10 @@ G_BEGIN_DECLS
* The cache flags.
**/
typedef enum {
- GS_UTILS_CACHE_FLAG_NONE = 0,
- GS_UTILS_CACHE_FLAG_WRITEABLE = 1 << 0,
- GS_UTILS_CACHE_FLAG_USE_HASH = 1 << 1,
+ GS_UTILS_CACHE_FLAG_NONE = 0,
+ GS_UTILS_CACHE_FLAG_WRITEABLE = 1 << 0,
+ GS_UTILS_CACHE_FLAG_USE_HASH = 1 << 1,
+ GS_UTILS_CACHE_FLAG_ENSURE_EMPTY = 1 << 2,
/*< private >*/
GS_UTILS_CACHE_FLAG_LAST
} GsUtilsCacheFlags;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]