MCPcopy Create free account
hub / github.com/wal-e/wal-e / clear_except

Method clear_except

wal_e/worker/prefetch.py:142–167  ·  view source on GitHub ↗
(self, retained_segments)

Source from the content-addressed store, hash-verified

140 shutil.rmtree(self.prefetched_dir, False, warn_on_cant_remove)
141
142 def clear_except(self, retained_segments):
143 sn = set(s.name for s in retained_segments)
144
145 try:
146 for n in os.listdir(self.running):
147 if n not in sn and re.match(storage.SEGMENT_REGEXP, n):
148 try:
149 shutil.rmtree(path.join(self.running, n))
150 except EnvironmentError as e:
151 if e.errno != errno.ENOENT:
152 raise
153 except EnvironmentError as e:
154 if e.errno != errno.ENOENT:
155 raise
156
157 try:
158 for n in os.listdir(self.prefetched_dir):
159 if n not in sn and re.match(storage.SEGMENT_REGEXP, n):
160 try:
161 os.remove(path.join(self.prefetched_dir, n))
162 except EnvironmentError as e:
163 if e.errno != errno.ENOENT:
164 raise
165 except EnvironmentError as e:
166 if e.errno != errno.ENOENT:
167 raise
168
169 def contains(self, segment):
170 return path.isfile(path.join(self.prefetched_dir, segment.name))

Callers 3

wal_restoreMethod · 0.95
test_cleanup_runningFunction · 0.80
test_cleanup_promotedFunction · 0.80

Calls 1

joinMethod · 0.45

Tested by 2

test_cleanup_runningFunction · 0.64
test_cleanup_promotedFunction · 0.64