[MIRROR] Fixed NTOS File Manager renaming and deletion (#3119)

* Fixed NTOS File Manager renaming and deletion (#56613)

* Fixed NTOS File Manager renaming and deletion

Co-authored-by: Andrew <mt.forspam@gmail.com>
This commit is contained in:
SkyratBot
2021-02-05 23:05:57 +01:00
committed by GitHub
parent fd7f1d1e78
commit 40552eac24
2 changed files with 19 additions and 6 deletions

View File

@@ -38,14 +38,27 @@
return return
RHDD.remove_file(file) RHDD.remove_file(file)
return TRUE return TRUE
if("PRG_rename") if("PRG_renamefile")
if(!HDD) if(!HDD)
return return
var/datum/computer_file/file = HDD.find_file_by_name(params["name"]) var/datum/computer_file/file = HDD.find_file_by_name(params["name"])
if(!file) if(!file)
return return
var/newname = params["new_name"] var/newname = reject_bad_name(params["new_name"])
if(!newname) if(!newname || newname != params["new_name"])
playsound(computer, 'sound/machines/terminal_error.ogg', 25, FALSE)
return
file.filename = newname
return TRUE
if("PRG_usbrenamefile")
if(!RHDD)
return
var/datum/computer_file/file = RHDD.find_file_by_name(params["name"])
if(!file)
return
var/newname = reject_bad_name(params["new_name"])
if(!newname || newname != params["new_name"])
playsound(computer, 'sound/machines/terminal_error.ogg', 25, FALSE)
return return
file.filename = newname file.filename = newname
return TRUE return TRUE

View File

@@ -19,7 +19,7 @@ export const NtosFileManager = (props, context) => {
usbconnected={usbconnected} usbconnected={usbconnected}
onUpload={file => act('PRG_copytousb', { name: file })} onUpload={file => act('PRG_copytousb', { name: file })}
onDelete={file => act('PRG_deletefile', { name: file })} onDelete={file => act('PRG_deletefile', { name: file })}
onRename={(file, newName) => act('PRG_rename', { onRename={(file, newName) => act('PRG_renamefile', {
name: file, name: file,
new_name: newName, new_name: newName,
})} })}
@@ -33,8 +33,8 @@ export const NtosFileManager = (props, context) => {
files={usbfiles} files={usbfiles}
usbconnected={usbconnected} usbconnected={usbconnected}
onUpload={file => act('PRG_copyfromusb', { name: file })} onUpload={file => act('PRG_copyfromusb', { name: file })}
onDelete={file => act('PRG_deletefile', { name: file })} onDelete={file => act('PRG_usbdeletefile', { name: file })}
onRename={(file, newName) => act('PRG_rename', { onRename={(file, newName) => act('PRG_usbrenamefile', {
name: file, name: file,
new_name: newName, new_name: newName,
})} })}