Skip to content

Commit

Permalink
修复上传文件时更新文件时间戳出错
Browse files Browse the repository at this point in the history
  • Loading branch information
jark006 committed Nov 12, 2024
1 parent 4204873 commit fb4506e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
8 changes: 4 additions & 4 deletions file_version_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 17, 0, 0),
prodvers=(1, 17, 0, 0),
filevers=(1,18, 0, 0),
prodvers=(1,18, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -31,12 +31,12 @@ VSVersionInfo(
'080404b0',
[StringStruct('CompanyName', 'Github@JARK006'),
StringStruct('FileDescription', 'FtpServer Github@JARK006'),
StringStruct('FileVersion', '1. 17.0.0'),
StringStruct('FileVersion', '1.18.0.0'),
StringStruct('InternalName', 'FtpServer'),
StringStruct('LegalCopyright', 'Copyright (C) 2024'),
StringStruct('OriginalFilename', 'FtpServer.exe'),
StringStruct('ProductName', 'FtpServer'),
StringStruct('ProductVersion', '1. 17.0.0')])
StringStruct('ProductVersion', '1.18.0.0')])
]),
VarFileInfo([VarStruct('Translation', [2052, 1200])])
]
Expand Down
14 changes: 12 additions & 2 deletions ftpServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

appName = "FTP Server"
appLabel = "FTP文件服务器"
appVersion = "v1.17"
appVersion = "v1.18"
appAuthor = "Github@JARK006"
githubLink = "https://github.com/jark006/FtpServer"
windowsTitle = f"{appLabel} {appVersion} By {appAuthor}"
Expand Down Expand Up @@ -78,7 +78,7 @@ def showHelp():
第三列: 权限, 详细配置如下。
第四列: 根目录路径。
详细权限配置
详细权限配置:
使用 "readonly" 或 "只读" (需保证文本格式为UTF-8) 设置 "只读权限"。
使用 "readwrite" 或 "读写" 设置 "读写权限"。
使用 "自定义" 权限设置, 从以下权限挑选自行组合(注意大小写):
Expand Down Expand Up @@ -114,6 +114,14 @@ def showHelp():
2. 若临时不需多用户配置, 可将文件重命名为其他名称。
3. 若配置文件存在 "中文汉字", 需确保文本为 "UTF-8" 格式。
4. 密码不要出现英文逗号 "," 字符, 以免和csv文本格式冲突。
==== 本软件相关链接 ====
开源地址: https://github.com/jark006/FtpServer
下载地址: https://github.com/jark006/FtpServer/releases
夸克网盘: https://pan.quark.cn/s/fb740c256653
百度云盘: https://pan.baidu.com/s/1955qjdrnPtxhNhtksjqvfg?pwd=6666 提取码: 6666
"""

helpWindows = tkinter.Toplevel(window)
Expand Down Expand Up @@ -378,6 +386,7 @@ def serverThreadFunV4():
handler.authorizer = authorizer
handler.encoding = "gbk" if settings.isGBK else "utf8"
serverV4 = ThreadedFTPServer(("0.0.0.0", settings.IPv4Port), handler)
serverV4.max_cons = 4096
print("[FTP IPv4] 开始运行")
isIPv4ThreadRunning = True
serverV4.serve_forever()
Expand Down Expand Up @@ -429,6 +438,7 @@ def serverThreadFunV6():
handler.authorizer = authorizer
handler.encoding = "gbk" if settings.isGBK else "utf8"
serverV6 = ThreadedFTPServer(("::", settings.IPv6Port), handler)
serverV6.max_cons = 4096
print("[FTP IPv6] 开始运行")
isIPv6ThreadRunning = True
serverV6.serve_forever()
Expand Down
8 changes: 5 additions & 3 deletions mypyftpdlib/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,9 @@ def elapsed2Str(elapsed: float):

if cmd in self.log_cmds_translate:
cmd = self.log_cmds_translate[cmd]
line = f"{cmd} {filename} {"完成" if completed else "失败"} {byte2Str(bytes)} {elapsed2Str(elapsed)}"
line = f"{cmd}{"成功" if completed else "失败"} {filename} {byte2Str(bytes)}"
if elapsed > 0:
line += f" {elapsed2Str(elapsed)} {(bytes/(2**20))/elapsed:.2f} MiB/s"
self.log(line)

# --- connection
Expand Down Expand Up @@ -2930,9 +2932,9 @@ def ftp_MFMT(self, path, timeval):
timefunc = time.gmtime if self.use_gmt_times else time.localtime
try:
# convert timeval string to epoch seconds
epoch = datetime.fromtimestamp(0, datetime.UTC)
epoch = datetime.fromtimestamp(0)
timeval_datetime_obj = datetime.strptime(timeval, '%Y%m%d%H%M%S')
timeval_secs = (timeval_datetime_obj - epoch).total_seconds()
timeval_secs = (timeval_datetime_obj - epoch).total_seconds() + 8 * 3600 # UTC+8
except ValueError:
why = "Invalid time format; expected: YYYYMMDDHHMMSS"
self.respond(f'550 {why}.')
Expand Down

0 comments on commit fb4506e

Please sign in to comment.