Skip to content

Commit

Permalink
调整文件重命名和移动时在目标文件存在的时候直接返回错误
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Sep 30, 2020
1 parent ef8867c commit a7f2031
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions class/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,6 @@ def CopyDir(self, get):
return public.returnMsg(False, 'DIR_COPY_ERR')

# 移动文件或目录

def MvFile(self, get):
if sys.version_info[0] == 2:
get.sfile = get.sfile.encode('utf-8')
Expand All @@ -874,6 +873,9 @@ def MvFile(self, get):
if not os.path.exists(get.sfile):
return public.returnMsg(False, 'FILE_NOT_EXISTS')

if os.path.exists(get.dfile):
return public.returnMsg(False,'目标文件名已存在!')

if get.dfile[-1] == '/':
get.dfile = get.dfile[:-1]

Expand All @@ -886,8 +888,7 @@ def MvFile(self, get):
self.move(get.sfile, get.dfile)
self.site_path_safe(get)
if hasattr(get, 'rename'):
public.WriteLog(
'TYPE_FILE', '[%s]重命名为[%s]' % (get.sfile, get.dfile))
public.WriteLog('TYPE_FILE', '[%s]重命名为[%s]' % (get.sfile, get.dfile))
return public.returnMsg(True, '重命名成功!')
else:
public.WriteLog('TYPE_FILE', 'MOVE_SUCCESS',
Expand Down

0 comments on commit a7f2031

Please sign in to comment.