Skip to content

Commit 3326d50

Browse files
committed
Symlinks should not be counted more than once
1 parent 8acbe6d commit 3326d50

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ldnp/deb.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import glob
2+
import math
23
import os
34

45
from pathlib import Path
@@ -28,11 +29,20 @@ def make_meta_info():
2829
return DebMetaInfo()
2930

3031
def generate_control_file(self):
31-
# this key is optional, however it shouldn't be a big deal to calculate the value
32-
installed_size = sum(
33-
map(
34-
os.path.getsize,
35-
glob.glob(str(self.appdir.path) + "/**", recursive=True),
32+
def get_size(path: str | os.PathLike):
33+
if os.path.islink(path):
34+
return 0
35+
36+
return os.path.getsize(path)
37+
38+
# this key is optional, however it's not a big deal to calculate the value
39+
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-installed-size
40+
installed_size = math.ceil(
41+
sum(
42+
map(
43+
get_size,
44+
glob.glob(str(self.appdir.path) + "/**", recursive=True),
45+
)
3646
)
3747
/ 1024
3848
)

0 commit comments

Comments
 (0)