Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ac2pic committed Aug 20, 2023
1 parent 9b51f13 commit 0926530
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type SaveListEntry = object
kind: PathComponent
path: string
mode: Mode
uid: Uid
gid: Gid


template respondWithOk(client: untyped) =
Expand Down Expand Up @@ -109,6 +111,7 @@ proc getRequiredFiles(targetDirectory: string, whitelist: seq[string]) : seq[tup
result = newSeq[tuple[kind: PathComponent, relativePath: string]]()
let shouldFilter = whitelist.len > 0
var s : Stat

for filePath in walkDirRec(targetDirectory, yieldFilter={pcFile,pcDir}, relative=true, skipSpecial=true):
let fullPath = targetDirectory / filePath
discard stat(fullPath.cstring, s)
Expand Down Expand Up @@ -190,10 +193,6 @@ proc updateSave(cmd: ClientRequest, client: AsyncSocket, mountId: string) {.asyn
else:
for (kind, relativePath) in getRequiredFiles(cmd.sourceFolder, cmd.selectOnly):
let targetPath = joinPath(mntFolder, relativePath)
if relativePath.startsWith("sce_sys"):
discard setuid(0)
else:
discard setuid(1)
if kind == pcDir:
discard mkdir(targetPath.cstring, 0o777)
elif kind == pcFile:
Expand All @@ -207,7 +206,6 @@ proc updateSave(cmd: ClientRequest, client: AsyncSocket, mountId: string) {.asyn
respondWithError(client, "E:COPY_FAILED")
failed = true
break
discard setuid(0)
discard umountSave(mntFolder, handle, false)
discard rmdir(mntFolder.cstring)
if failed:
Expand Down Expand Up @@ -238,7 +236,7 @@ proc listSaveFiles(cmd: ClientRequest, client: AsyncSocket, mountId: string) {.a
if stat((mntFolder / relativePath).cstring, s) == -1:
respondWithError(client, "E:STAT_FAILED-" & errno.toHex(8))
break
listEntries.add SaveListEntry(kind: kind, path: relativePath, mode: s.st_mode)
listEntries.add SaveListEntry(kind: kind, path: relativePath, mode: s.st_mode, uid: s.st_uid, gid: s.st_gid)
respondWithJson(client, %listEntries)
discard umountSave(mntFolder, handle, false)
discard rmdir(mntFolder.cstring)
Expand Down

0 comments on commit 0926530

Please sign in to comment.