Skip to content

Commit

Permalink
even less hardcoding
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFJcurve committed Nov 13, 2024
1 parent 4668107 commit b31b935
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def receive_token():
print("Could not find the fucking file with file id " + file_hash)
return jsonify({"error": "Can't find file hash"}), 400

file_path = os.path.join('sources', files[1])
file_path = os.path.join(SOURCES_FOLDER, files[1])

with open(file_path, 'r', encoding="utf-8") as f:
file_with_extension = json.loads(f.read())['header']['file_name']

with open(os.path.join('uploads', file_with_extension), 'rb') as f:
with open(os.path.join(UPLOADS_FOLDER, file_with_extension), 'rb') as f:
file_data = f.read()

file_blob = io.BytesIO(file_data)
Expand Down
4 changes: 2 additions & 2 deletions backend/code/p2p_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def listen_for_messages(self):
elif message["type"] == "response_block":
self.save_block(message)
self.tmp_to_file(os.path.join(
'uploads', Path(message['file_name']).stem + '.tmp'))
UPLOADS_FOLDER, Path(message['file_name']).stem + '.tmp'))
else:
print("Invalid message type: " + message["type"])
else:
Expand All @@ -244,7 +244,7 @@ def tmp_to_file(self, tmp_file_path):
# print("CONTENT:", content)
s = content.values().join()

with open(os.path.join('uploads', file_with_extension), 'w+', encoding="utf-8") as f:
with open(os.path.join(UPLOADS_FOLDER, file_with_extension), 'w+', encoding="utf-8") as f:
f.write(s)

os.remove(tmp_file_path)

0 comments on commit b31b935

Please sign in to comment.