File: metadata-nuke-junk-data.patch

package info (click to toggle)
gvfs 1.58.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,452 kB
  • sloc: ansic: 105,955; python: 1,461; xml: 944; sh: 146; makefile: 54
file content (41 lines) | stat: -rw-r--r-- 1,405 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Christian Kellner <gicmo@gnome.org>
Date: Wed, 4 Nov 2009 16:40:24 +0100
Subject: Nuke the metadata file if magic blob is wrong

Related to https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/405432,
https://gitlab.gnome.org/GNOME/gvfs/-/issues/255,
https://gitlab.gnome.org/GNOME/gvfs/-/issues/122,
https://bugzilla.gnome.org/show_bug.cgi?id=750113,
https://bugzilla.gnome.org/show_bug.cgi?id=598561

TODO: This was never applied upstream, but it's unclear to me why it was
marked as obsolete -smcv

Forwarded: https://bugzilla.gnome.org/show_bug.cgi?id=598561
Forwarded: https://bugzilla.gnome.org/attachment.cgi?id=146922
Applied-upstream: no, marked as obsolete with a reference to https://bugzilla.gnome.org/show_bug.cgi?id=750113
---
 metadata/metatree.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/metadata/metatree.c b/metadata/metatree.c
index d2bf9ec..b2bee15 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -451,7 +451,15 @@ meta_tree_init (MetaTree *tree)
   if (memcmp (tree->header->magic, MAGIC, MAGIC_LEN) != 0)
     {
       g_warning ("can't init metadata tree %s: wrong magic", tree->filename);
-      goto err;
+      if (!tree->for_write)
+        goto err;
+
+      meta_tree_clear (tree);
+
+      if (g_unlink (tree->filename) != 0)
+        goto err;
+
+      goto retry;
     }
 
   if (tree->header->major != MAJOR_VERSION)