MCPcopy
hub / github.com/gpustack/gpustack / _getsize

Function _getsize

gpustack/utils/file.py:112–138  ·  view source on GitHub ↗
(path: str, visited: set, cache: dict)

Source from the content-addressed store, hash-verified

110
111
112def _getsize(path: str, visited: set, cache: dict) -> int:
113 real_path = os.path.realpath(path)
114
115 if os.path.islink(path):
116 return _getsize(real_path, visited, cache)
117 elif os.path.isfile(real_path):
118 return os.path.getsize(real_path)
119 elif os.path.isdir(real_path):
120 if real_path in visited:
121 return 0
122 visited.add(real_path)
123
124 if real_path in cache:
125 return cache[real_path]
126
127 total = 0
128 with os.scandir(real_path) as entries:
129 for entry in entries:
130 try:
131 total += _getsize(entry.path, visited, cache)
132 except FileNotFoundError:
133 pass
134
135 cache[real_path] = total
136 return total
137
138 raise FileNotFoundError(f"Path does not exist: {path}")
139
140
141def get_sharded_file_paths(file_path: str) -> str:

Callers 1

getsizeFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected