Skip to content

Commit

Permalink
Fixed critical bug with zipping
Browse files Browse the repository at this point in the history
Now it deletes any zips and hashes before creating new ones
  • Loading branch information
DefinetlyNotAI committed Sep 17, 2024
1 parent 3d532f6 commit c69c316
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions .idea/webResources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions CODE/Logicytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,17 @@ def __run_other_script(script: str) -> None:
# Zip generated files

if action == "modded":
zip_loc_mod, hash_loc = zip_and_hash("..\\MODS", "MODS", action)
zip_loc_mod, hash_loc, deleted_files_zip, deleted_files_hash = zip_and_hash("..\\MODS", "MODS", action)
log.info(zip_loc_mod)
log.debug(hash_loc)
log.debug(deleted_files_zip)
log.debug(deleted_files_hash)

zip_loc, hash_loc = zip_and_hash("..\\CODE", "CODE", action)
zip_loc, hash_loc, deleted_files_zip, deleted_files_hash = zip_and_hash("..\\CODE", "CODE", action)
log.info(zip_loc)
log.debug(hash_loc)
log.debug(deleted_files_zip)
log.debug(deleted_files_hash)

# Attempt event log deletion
attempt_hide()
Expand Down
14 changes: 14 additions & 0 deletions CODE/_zipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ def move_files(filename: str):
shutil.move(f"{filename}.hash", "../ACCESS/DATA/Hashes")


def check_and_delete_files_with_suffix(directory: str, suffix: str):
deleted_files = []
for filename in os.listdir(directory):
if filename.endswith(suffix):
file_path = os.path.join(directory, filename)
os.remove(file_path)
deleted_files.append(file_path)
return deleted_files


def zip_and_hash(path: str, name: str, action: str) -> tuple:
deleted_files_hash = check_and_delete_files_with_suffix('../ACCESS/DATA/Hashes', '.hash')
deleted_files_zip = check_and_delete_files_with_suffix('../ACCESS/DATA/Zip', '.zip')
today = date.today()
filename = f"Logicytics_{name}_{action}_{today.strftime('%Y-%m-%d')}"
files_to_zip = get_files_to_zip(path)
Expand All @@ -58,4 +70,6 @@ def zip_and_hash(path: str, name: str, action: str) -> tuple:
return (
f"Zip file moved to ../ACCESS/DATA/Zip/{filename}.zip",
f"SHA256 Hash file moved to ../ACCESS/DATA/Hashes/{filename}.hash",
deleted_files_zip,
deleted_files_hash
)
15 changes: 8 additions & 7 deletions DCO.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!-- saved from url=(0033)https://developercertificate.org/ -->
<html><!--
<!--
File: Developer_Certificate_of_Origin.md
Editor: None, you wimpy wysiwyg people...this is hand crafted!
Editor: None, you wimpy wysiwyg people...this is handcrafted!
What are you doing reading this anyway??? - Original Authors message
--><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<pre>Developer Certificate of Origin
-->

<pre>
Developer Certificate of Origin
Version 1.1

Copyright (C) 2024 Logicytics and its contributors.
Expand Down Expand Up @@ -39,4 +39,5 @@ By making a contribution to this project, I certify that:
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
this project or the open source license(s) involved.
</pre>

0 comments on commit c69c316

Please sign in to comment.