Skip to content

Commit

Permalink
introduce ignore_secondlayer_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hzhreal committed Dec 20, 2024
1 parent e80808f commit 512b052
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions cogs/createsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ async def createsave(
ctx: discord.ApplicationContext,
savename: Option(str, description="The name of the save."), # type: ignore
saveblocks: saveblocks_annotation, # type: ignore
playstation_id: Option(str, description=PS_ID_DESC, default="") # type: ignore
playstation_id: Option(str, description=PS_ID_DESC, default=""), # type: ignore
ignore_secondlayer_checks: bool = False
) -> None:

newUPLOAD_ENCRYPTED, newUPLOAD_DECRYPTED, newDOWNLOAD_ENCRYPTED, newPNG_PATH, newPARAM_PATH, newDOWNLOAD_DECRYPTED, newKEYSTONE_PATH = initWorkspace()
Expand Down Expand Up @@ -146,7 +147,7 @@ async def createsave(
await handleTitles(scesys_local, user_id, SAVEDATA_DIRECTORY=savename, SAVEDATA_BLOCKS=saveblocks)
title_id = await obtainCUSA(scesys_local)

if len(uploaded_file_paths_special) <= CREATESAVE_ENC_CHECK_LIMIT: # dont want to create unnecessary overhead
if len(uploaded_file_paths_special) <= CREATESAVE_ENC_CHECK_LIMIT and not ignore_secondlayer_checks: # dont want to create unnecessary overhead
for gamesave in uploaded_file_paths_special:
embsl = discord.Embed(
title=f"Gamesaves: Second layer\n{gamesave}",
Expand Down
5 changes: 3 additions & 2 deletions cogs/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ async def encrypt(
ctx: discord.ApplicationContext,
upload_individually: Option(bool, description="Choose if you want to upload the decrypted files one by one, or the ones you want at once."), # type: ignore
include_sce_sys: Option(bool, description="Choose if you want to upload the contents of the 'sce_sys' folder."), # type: ignore
playstation_id: Option(str, description=PS_ID_DESC, default="") # type: ignore
playstation_id: Option(str, description=PS_ID_DESC, default=""), # type: ignore
ignore_secondlayer_checks: bool = False
) -> None:

newUPLOAD_ENCRYPTED, newUPLOAD_DECRYPTED, newDOWNLOAD_ENCRYPTED, newPNG_PATH, newPARAM_PATH, newDOWNLOAD_DECRYPTED, newKEYSTONE_PATH = initWorkspace()
Expand Down Expand Up @@ -103,7 +104,7 @@ async def encrypt(
await C1ftp.dlparamonly_grab(location_to_scesys)
title_id = await obtainCUSA(newPARAM_PATH)

completed = await replaceDecrypted(d_ctx, C1ftp, files, title_id, mount_location_new, upload_individually, newUPLOAD_DECRYPTED, save, pfs_header["size"])
completed = await replaceDecrypted(d_ctx, C1ftp, files, title_id, mount_location_new, upload_individually, newUPLOAD_DECRYPTED, save, pfs_header["size"], ignore_secondlayer_checks)

if include_sce_sys:
if len(await aiofiles.os.listdir(newUPLOAD_DECRYPTED)) > 0:
Expand Down
11 changes: 8 additions & 3 deletions utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ async def replaceDecrypted(
upload_individually: bool,
upload_decrypted: str,
savePairName: str,
savesize: int
savesize: int,
ignore_secondlayer_checks: bool
) -> list[str]:

"""Used in the encrypt command to replace files one by one, or how many you want at once."""
Expand All @@ -417,7 +418,9 @@ async def replaceDecrypted(
attachmentPath = await upload1(d_ctx, upload_decrypted)
newPath = os.path.join(upload_decrypted, lastN)
await aiofiles.os.rename(attachmentPath, newPath)
await crypthelp.extra_import(Crypto, titleid, newPath)

if not ignore_secondlayer_checks:
await crypthelp.extra_import(Crypto, titleid, newPath)

await fInstance.replacer(cwdHere, lastN)
completed.append(file)
Expand Down Expand Up @@ -487,7 +490,9 @@ async def send_chunk(msg_container: list[discord.Message], chunk: str) -> None:
filePath = os.path.join(upload_decrypted, file)
newRename = os.path.join(upload_decrypted, lastN)
await aiofiles.os.rename(filePath, newRename)
await crypthelp.extra_import(Crypto, titleid, newRename)

if not ignore_secondlayer_checks:
await crypthelp.extra_import(Crypto, titleid, newRename)

await fInstance.replacer(cwdHere, lastN)
completed.append(lastN)
Expand Down

0 comments on commit 512b052

Please sign in to comment.