Skip to content

Commit

Permalink
Print a more helpful error message if manifest path is not writable
Browse files Browse the repository at this point in the history
  • Loading branch information
bbhtt committed Nov 5, 2023
1 parent 7489b06 commit 2e78340
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions src/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from enum import IntEnum
import logging
import os
import errno
import sys

import aiohttp
from lxml.etree import XMLSyntaxError
Expand Down Expand Up @@ -445,25 +447,38 @@ def get_outdated_external_data(self) -> t.List[ExternalBase]:
]

def _update_manifest(self, path, datas, changes):
path_has_changes = False
for data in datas:
if data.new_version is None:
continue
try:
path_has_changes = False
for data in datas:
if data.new_version is None:
continue

data.update()
if data.new_version.version is not None:
message = "Update {} to {}".format(
data.filename, data.new_version.version
)
data.update()
if data.new_version.version is not None:
message = "Update {} to {}".format(
data.filename, data.new_version.version
)
else:
message = "Update {}".format(data.filename)

changes[message] = None
path_has_changes = True

if path_has_changes:
log.info("Updating %s", path)
self._dump_manifest(path)
except OSError as e:
if e.errno in (errno.EPERM, errno.EACCES):
log.error("Permission denied writing to file")
elif e.errno == errno.EROFS:
log.error("The file is read-only")
if os.path.exists("/.flatpak-info"):
log.info(
"Running inside flatpak. Please give it filesystem access using --filesystem"
)
else:
message = "Update {}".format(data.filename)

changes[message] = None
path_has_changes = True

if path_has_changes:
log.info("Updating %s", path)
self._dump_manifest(path)
log.error(e)
sys.exit(1)

def _update_appdata(self):
if not self.app_id:
Expand Down

0 comments on commit 2e78340

Please sign in to comment.