1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 07caching.dpatch by Chris J Arges <chris.j.arges@canonical.com>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: This patch backports caching support. (LP: #1013446)
8
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/cached_ops.py duplicity-0.6.18/cached_ops.py
9
--- duplicity-0.6.18~/cached_ops.py 1969-12-31 18:00:00.000000000 -0600
10
+++ duplicity-0.6.18/cached_ops.py 2012-11-14 10:38:07.139372741 -0600
12
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
14
+# Copyright 2012 Google Inc.
16
+# This file is part of duplicity.
18
+# Duplicity is free software; you can redistribute it and/or modify it
19
+# under the terms of the GNU General Public License as published by the
20
+# Free Software Foundation; either version 2 of the License, or (at your
21
+# option) any later version.
23
+# Duplicity is distributed in the hope that it will be useful, but
24
+# WITHOUT ANY WARRANTY; without even the implied warranty of
25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26
+# General Public License for more details.
28
+# You should have received a copy of the GNU General Public License
29
+# along with duplicity; if not, write to the Free Software Foundation,
30
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
+"""Cache-wrapped functions for grp and pwd lookups."""
38
+class CachedCall(object):
39
+ """Decorator for caching the results of function calls."""
41
+ def __init__(self, f):
45
+ def __call__(self, *args):
47
+ return self.cache[args]
48
+ except (KeyError, TypeError), e:
49
+ result = self.f(*args)
50
+ if not isinstance(e, TypeError):
51
+ # TypeError most likely means that args is not hashable
52
+ self.cache[args] = result
58
+ return grp.getgrgid(gid)
63
+ return grp.getgrnam(name)
68
+ return pwd.getpwnam(name)
73
+ return pwd.getpwuid(uid)
74
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/cached_ops.py duplicity-0.6.18/duplicity/cached_ops.py
75
--- duplicity-0.6.18~/duplicity/cached_ops.py 1969-12-31 18:00:00.000000000 -0600
76
+++ duplicity-0.6.18/duplicity/cached_ops.py 2012-11-14 10:38:11.539372820 -0600
78
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
80
+# Copyright 2012 Google Inc.
82
+# This file is part of duplicity.
84
+# Duplicity is free software; you can redistribute it and/or modify it
85
+# under the terms of the GNU General Public License as published by the
86
+# Free Software Foundation; either version 2 of the License, or (at your
87
+# option) any later version.
89
+# Duplicity is distributed in the hope that it will be useful, but
90
+# WITHOUT ANY WARRANTY; without even the implied warranty of
91
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92
+# General Public License for more details.
94
+# You should have received a copy of the GNU General Public License
95
+# along with duplicity; if not, write to the Free Software Foundation,
96
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
98
+"""Cache-wrapped functions for grp and pwd lookups."""
104
+class CachedCall(object):
105
+ """Decorator for caching the results of function calls."""
107
+ def __init__(self, f):
111
+ def __call__(self, *args):
113
+ return self.cache[args]
114
+ except (KeyError, TypeError), e:
115
+ result = self.f(*args)
116
+ if not isinstance(e, TypeError):
117
+ # TypeError most likely means that args is not hashable
118
+ self.cache[args] = result
124
+ return grp.getgrgid(gid)
129
+ return grp.getgrnam(name)
134
+ return pwd.getpwnam(name)
139
+ return pwd.getpwuid(uid)
140
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/path.py duplicity-0.6.18/duplicity/path.py
141
--- duplicity-0.6.18~/duplicity/path.py 2012-02-29 13:24:04.000000000 -0600
142
+++ duplicity-0.6.18/duplicity/path.py 2012-11-14 10:38:11.539372820 -0600
147
-import stat, errno, socket, time, re, gzip, pwd, grp
148
+import stat, errno, socket, time, re, gzip
150
from duplicity import tarfile
151
from duplicity import file_naming
153
from duplicity import librsync
154
from duplicity import log #@UnusedImport
155
from duplicity import dup_time
156
+from duplicity import cached_ops
157
from duplicity.lazy import * #@UnusedWildImport
159
_copy_blocksize = 64 * 1024
160
@@ -206,13 +207,13 @@
162
if globals.numeric_owner:
164
- self.stat.st_uid = pwd.getpwnam(tarinfo.uname)[2]
165
+ self.stat.st_uid = cached_ops.getpwnam(tarinfo.uname)[2]
167
self.stat.st_uid = tarinfo.uid
169
if globals.numeric_owner:
171
- self.stat.st_gid = grp.getgrnam(tarinfo.gname)[2]
172
+ self.stat.st_gid = cached_ops.getgrnam(tarinfo.gname)[2]
174
self.stat.st_gid = tarinfo.gid
176
@@ -284,11 +285,11 @@
177
ti.mtime = int(self.stat.st_mtime)
180
- ti.uname = pwd.getpwuid(ti.uid)[0]
181
+ ti.uname = cached_ops.getpwuid(ti.uid)[0]
185
- ti.gname = grp.getgrgid(ti.gid)[0]
186
+ ti.gname = cached_ops.getgrgid(ti.gid)[0]
190
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' duplicity-0.6.18~/duplicity/tarfile.py duplicity-0.6.18/duplicity/tarfile.py
191
--- duplicity-0.6.18~/duplicity/tarfile.py 2012-02-29 13:24:04.000000000 -0600
192
+++ duplicity-0.6.18/duplicity/tarfile.py 2012-11-14 10:38:11.539372820 -0600
201
+from duplicity import cached_ops
202
+grp = pwd = cached_ops
204
# from tarfile import *
205
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]