Skip to content

Commit

Permalink
sprintfix: 修复 Proxy 文件同步扫描不存在文件创建时间戳的问题 (fixed #1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuoZhuoCrayon committed Aug 28, 2023
1 parent 2dc4c7a commit f9f8099
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions script_tools/setup_pagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ class ExecuteWinCmdError(Exception):

try:
# import 3rd party libraries here, in case the python interpreter does not have them
import impacket # noqa
import paramiko # noqa
import requests # noqa

import impacket # noqa

# import psutil

except ImportError as err:
Expand Down Expand Up @@ -369,13 +370,14 @@ def download_file(url: str, dest_dir: str):
# NOTE the stream=True parameter below
local_file = os.path.join(dest_dir, local_filename)

# 如果修改时间临近,跳过下载,避免多个 setup 脚本文件互相覆盖
mtimestamp: float = os.path.getmtime(local_file)
if time.time() - mtimestamp < 10:
report_log(
"download_file", f"File download skipped due to sync time approaching, mtimestamp -> {mtimestamp}"
)
return
if os.path.exists(local_file):
# 如果修改时间临近,跳过下载,避免多个 setup 脚本文件互相覆盖
mtimestamp: float = os.path.getmtime(local_file)
if time.time() - mtimestamp < 10:
report_log(
"download_file", f"File download skipped due to sync time approaching, mtimestamp -> {mtimestamp}"
)
return

r = requests.get(url, stream=True)
r.raise_for_status()
Expand Down
18 changes: 10 additions & 8 deletions script_tools/setup_pagent2.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def arg_parser() -> argparse.ArgumentParser:

try:
# import 3rd party libraries here, in case the python interpreter does not have them
import impacket # noqa
import paramiko # noqa
import requests # noqa

import impacket # noqa

# import psutil

except ImportError as err:
Expand Down Expand Up @@ -415,13 +416,14 @@ def download_file(url: str, dest_dir: str):
# NOTE the stream=True parameter below
local_file = os.path.join(dest_dir, local_filename)

# 如果修改时间临近,跳过下载,避免多个 setup 脚本文件互相覆盖
mtimestamp: float = os.path.getmtime(local_file)
if time.time() - mtimestamp < 10:
logger.logging(
"download_file", f"File download skipped due to sync time approaching, mtimestamp -> {mtimestamp}"
)
return
if os.path.exists(local_file):
# 如果修改时间临近,跳过下载,避免多个 setup 脚本文件互相覆盖
mtimestamp: float = os.path.getmtime(local_file)
if time.time() - mtimestamp < 10:
logger.logging(
"download_file", f"File download skipped due to sync time approaching, mtimestamp -> {mtimestamp}"
)
return

r = requests.get(url, stream=True)
r.raise_for_status()
Expand Down

0 comments on commit f9f8099

Please sign in to comment.