diff --git a/pyproject.toml b/pyproject.toml index 056748e..019889e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "rda_python_common" -version = "1.0.43" +version = "1.0.44" authors = [ { name="Zaihua Ji", email="zji@ucar.edu" }, ] diff --git a/src/rda_python_common/PgFile.py b/src/rda_python_common/PgFile.py index 8aef37f..204c834 100644 --- a/src/rda_python_common/PgFile.py +++ b/src/rda_python_common/PgFile.py @@ -1636,7 +1636,10 @@ 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 if info['isfile'] else local_path_size(file) + if info['isfile'] == 0 and logact&PgLOG.PFSIZE: + info['data_size'] = local_path_size(file) + else: + info['data_size'] = fstat.st_size info['fname'] = op.basename(file) if not opt: return info if opt&64 and info['isfile'] and info['data_size'] < PgLOG.PGLOG['MINSIZE']: @@ -2573,7 +2576,7 @@ def local_file_size(file, opt = 0, logact = 0): if opt&4: lmsg(file, PgLOG.PGLOG['MISSFILE'], logact) return -1 # file not eixsts - info = check_local_file(file, 0, logact) + info = check_local_file(file, 0, logact|PgLOG.PFSIZE) if info: if info['isfile'] and info['data_size'] < PgLOG.PGLOG['MINSIZE']: if opt: diff --git a/src/rda_python_common/PgLOG.py b/src/rda_python_common/PgLOG.py index 1e78a97..b7756e0 100644 --- a/src/rda_python_common/PgLOG.py +++ b/src/rda_python_common/PgLOG.py @@ -67,6 +67,7 @@ SKPTRC = (0x400000) # action to skip tracing when log errors UCNAME = (0x800000) # action to change query field names to upper case UCLWEX = (0x800015) # UCNAME|MSGLOG|WARNLG|EXITLG +PFSIZE = (0x1000000) # total file size under a path SUCCESS = 1 # Successful function call FINISH = 2 # go through a function, including time out