Skip to content

Commit 29bcf2c

Browse files
committed
_1password-gui: Fix update-sources.py truncation bug
Update tooling missed to truncate sources.json before or after a write. Possibly allowing remnant bytes from the older version.
1 parent 186819c commit 29bcf2c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkgs/by-name/_1/_1password-gui/update-sources.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
class Sources(OrderedDict):
1616
def __init__(self):
17-
self._jsonfp = open("sources.json", "r+")
18-
self.update(json.load(self._jsonfp))
19-
self._jsonfp.seek(0, os.SEEK_SET)
17+
with open("sources.json", "r") as fp:
18+
self.update(json.load(fp))
2019

2120
def persist(self):
22-
json.dump(self, self._jsonfp, indent=2)
23-
self._jsonfp.write("\n") # keep fmt.check happy
24-
21+
with open("sources.json", "w") as fp:
22+
print(json.dumps(self, indent=2), file=fp)
2523

2624
class GPG:
2725
def __new__(cls):

0 commit comments

Comments
 (0)