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 3, 2023
1 parent 7489b06 commit 6c2502d
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions src/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import asyncio
from enum import IntEnum
import logging
import os
import errno, os, sys

import aiohttp
from lxml.etree import XMLSyntaxError
Expand Down Expand Up @@ -445,25 +445,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 (IOError, OSError) as e:
if e.errno in (errno.EPERM, errno.EACCES, errno.EROFS):
log.error(
"Please make sure the path is writable and has appropriate permissions"
)
if os.path.exists("/.flatpak-info"):
log.error(
"You are running inside a sandbox. Please make sure it has appropriate filesystem permissions"
)
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 6c2502d

Please sign in to comment.