Skip to content

Commit 722d456

Browse files
author
Alexander Popov
committed
fix: PGPRO-4183, add try .. except FileNotFoundError on size dir
1 parent 8682230 commit 722d456

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

mamonsu/plugins/system/linux/pg_probackup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ def dir_size(self, path):
2424
total_size = 0
2525
for dirpath, dirnames, filenames in tree:
2626
for file in filenames:
27-
size = os.path.getsize(os.path.join(dirpath, file))
28-
if 0 < size < self.block_size:
29-
size = round(size / self.block_size) * self.block_size + self.block_size
27+
try:
28+
size = os.path.getsize(os.path.join(dirpath, file))
29+
if 0 < size < self.block_size:
30+
size = round(size / self.block_size) * self.block_size + self.block_size
31+
except FileNotFoundError as e:
32+
self.log.debug(str(e))
33+
size = 0
3034
total_size += size
31-
size = os.path.getsize(dirpath)
35+
try:
36+
size = os.path.getsize(dirpath)
37+
except FileNotFoundError as e:
38+
self.log.debug(str(e))
39+
size = 0
3240
total_size += size
3341
return total_size
3442

0 commit comments

Comments
 (0)