Skip to content

Commit

Permalink
fixed temp issues, folder selection actually works
Browse files Browse the repository at this point in the history
  • Loading branch information
int-72h committed Jun 1, 2022
1 parent 8ca9feb commit cb79630
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from shutil import move
import httpx

parser = argparse.ArgumentParser(description="Manage Open Fortress installation.")
parser = argparse.ArgumentParser(description="Manage Open Fortress installation. Example: cli.py upgrade <dir>")
parser.add_argument("action", type=str, help='action to execute on a directory, currently only "upgrade"')
parser.add_argument("directory", type=str, help='action to execute on a directory, currently only "upgrade"')
parser.add_argument("-u", default="http://toast.openfortress.fun/toast/", help="url to fetch data from")
Expand All @@ -35,7 +35,7 @@
revisions = fetch_revisions(args.u, installed_revision, latest_revision)
changes = replay_changes(revisions)

temp_dir = tempfile.TemporaryDirectory()
temp_dir = tempfile.mkdtemp()
temp_path = Path(temp_dir.name)

writes = list(filter(lambda x: x["type"] == TYPE_WRITE, changes))
Expand Down
9 changes: 4 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path, PosixPath, WindowsPath
from sys import exit
from tvn import *
from shutil import copy
from shutil import move
import httpx

from PyQt5 import QtCore, QtGui, QtWidgets, Qt
Expand Down Expand Up @@ -100,7 +100,7 @@ def retranslateUi(self, MainWindow):

def clickBrowse(self):
gamepath = QFileDialog.getExistingDirectory(MainWindow, "Game path", "")
# self.lineEdit.setText(gamepath[0].removesuffix("gameinfo.txt"))
self.lineEdit.setText(gamepath[0])
revision = get_installed_revision(Path(self.lineEdit.text()))
if revision >= 0:
self.label_3.setText("Installed Revision: " + str(revision))
Expand Down Expand Up @@ -130,7 +130,7 @@ def clickUpdate(self):
revisions = fetch_revisions(self.lineEdit_2.text(), installed_revision, latest_revision)
changes = replay_changes(revisions)

temp_dir = tempfile.TemporaryDirectory()
temp_dir = tempfile.mkdtemp()
temp_path = Path(temp_dir.name)

writes = list(filter(lambda x: x["type"] == TYPE_WRITE, changes))
Expand All @@ -154,8 +154,7 @@ def clickUpdate(self):
pass

for x in writes:
copy(temp_path / x["object"], str(game_path) + "/" + x["path"])
os.remove(temp_path/x["object"])
move(temp_path / x["object"], str(game_path) + "/" + x["path"])

(game_path / ".revision").touch(0o777)
(game_path / ".revision").write_text(str(latest_revision))
Expand Down

0 comments on commit cb79630

Please sign in to comment.