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

Method create

wal_e/worker/prefetch.py:91–128  ·  view source on GitHub ↗

A best-effort attempt to create directories. Warnings are issued to the user if those directories could not created or if they don't exist. The caller should only call this function if the user requested prefetching (i.e. concurrency) to avoid spurious warni

(self, segment)

Source from the content-addressed store, hash-verified

89 return path.join(self.running, segment.name)
90
91 def create(self, segment):
92 """A best-effort attempt to create directories.
93
94 Warnings are issued to the user if those directories could not
95 created or if they don't exist.
96
97 The caller should only call this function if the user
98 requested prefetching (i.e. concurrency) to avoid spurious
99 warnings.
100 """
101
102 def lackadaisical_mkdir(place):
103 ok = False
104
105 place = path.realpath(place)
106
107 try:
108 os.makedirs(place, 0o700)
109 ok = True
110 except EnvironmentError as e:
111 if e.errno == errno.EEXIST:
112 # Has already been created: this is the most
113 # common situation, and is fine.
114 ok = True
115 else:
116 logger.warning(
117 msg='could not create prefetch directory',
118 detail=('Prefetch directory creation target: {0}, {1}'
119 .format(place, e.strerror)))
120
121 return ok
122
123 ok = True
124
125 for d in [self.prefetched_dir, self.running]:
126 ok &= lackadaisical_mkdir(d)
127
128 lackadaisical_mkdir(self.seg_dir(segment))
129
130 def clear(self):
131 def warn_on_cant_remove(function, path, excinfo):

Callers 2

wal_prefetchMethod · 0.95
start_prefetchesFunction · 0.45

Calls 1

seg_dirMethod · 0.95

Tested by

no test coverage detected