Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rda_python_common"
version = "1.0.41"
version = "1.0.42"
authors = [
{ name="Zaihua Ji", email="[email protected]" },
]
Expand Down
16 changes: 14 additions & 2 deletions src/rda_python_common/PgFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ def local_file_stat(file, fstat, opt, logact):

info = {}
info['isfile'] = (1 if stat.S_ISREG(fstat.st_mode) else 0)
info['data_size'] = fstat.st_size
info['data_size'] = fstat.st_size if info['isfile'] else local_path_size(file)
info['fname'] = op.basename(file)
if not opt: return info
if opt&64 and info['isfile'] and info['data_size'] < PgLOG.PGLOG['MINSIZE']:
Expand Down Expand Up @@ -1665,6 +1665,18 @@ def local_file_stat(file, fstat, opt, logact):

return info

#
# get total size of files under a given path
#
def local_path_size(pname):

if not pname: pname = '.' # To get size of current directory
size = 0
for path, dirs, files in os.walk(pname):
for f in files:
size += os.path.getsize(os.path.join(path, f))
return size

#
# check and get file status information of a file on remote host
#
Expand Down Expand Up @@ -2557,7 +2569,7 @@ def rda_file_size(file, host, opt = 0, logact = 0):
#
def local_file_size(file, opt = 0, logact = 0):

if not op.isfile(file):
if not op.exists(file):
if opt&4: lmsg(file, PgLOG.PGLOG['MISSFILE'], logact)
return -1 # file not eixsts

Expand Down