check for contents of bookmark files to improve migration
This commit is contained in:
parent
7962da9454
commit
5a60869f8e
9
debian/openwebrx.postinst
vendored
9
debian/openwebrx.postinst
vendored
@ -7,6 +7,7 @@ OWRX_USER="openwebrx"
|
|||||||
OWRX_DATADIR="/var/lib/openwebrx"
|
OWRX_DATADIR="/var/lib/openwebrx"
|
||||||
OWRX_USERS_FILE="${OWRX_DATADIR}/users.json"
|
OWRX_USERS_FILE="${OWRX_DATADIR}/users.json"
|
||||||
OWRX_SETTINGS_FILE="${OWRX_DATADIR}/settings.json"
|
OWRX_SETTINGS_FILE="${OWRX_DATADIR}/settings.json"
|
||||||
|
OWRX_BOOKMARKS_FILE="${OWRX_DATADIR}/bookmarks.json"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
configure|reconfigure)
|
configure|reconfigure)
|
||||||
@ -17,19 +18,23 @@ case "$1" in
|
|||||||
if [ ! -d "${OWRX_DATADIR}" ] && [ ! -L "${OWRX_DATADIR}" ]; then mkdir "${OWRX_DATADIR}"; fi
|
if [ ! -d "${OWRX_DATADIR}" ] && [ ! -L "${OWRX_DATADIR}" ]; then mkdir "${OWRX_DATADIR}"; fi
|
||||||
chown "${OWRX_USER}". ${OWRX_DATADIR}
|
chown "${OWRX_USER}". ${OWRX_DATADIR}
|
||||||
|
|
||||||
|
# create empty config files now to avoid permission problems later
|
||||||
if [ ! -e "${OWRX_USERS_FILE}" ]; then
|
if [ ! -e "${OWRX_USERS_FILE}" ]; then
|
||||||
# create an empty users file now to avoid permission problems later
|
|
||||||
echo "[]" > "${OWRX_USERS_FILE}"
|
echo "[]" > "${OWRX_USERS_FILE}"
|
||||||
chown "${OWRX_USER}". "${OWRX_USERS_FILE}"
|
chown "${OWRX_USER}". "${OWRX_USERS_FILE}"
|
||||||
chmod 0600 "${OWRX_USERS_FILE}"
|
chmod 0600 "${OWRX_USERS_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "${OWRX_SETTINGS_FILE}" ]; then
|
if [ ! -e "${OWRX_SETTINGS_FILE}" ]; then
|
||||||
# create an empty settings file now to avoid permission problems later
|
|
||||||
echo "{}" > "${OWRX_SETTINGS_FILE}"
|
echo "{}" > "${OWRX_SETTINGS_FILE}"
|
||||||
chown "${OWRX_USER}". "${OWRX_SETTINGS_FILE}"
|
chown "${OWRX_USER}". "${OWRX_SETTINGS_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "${OWRX_BOOKMARKS_FILE}" ]; then
|
||||||
|
touch "${OWRX_BOOKMARKS_FILE}"
|
||||||
|
chown "${OWRX_USER}". "${OWRX_BOOKMARKS_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
db_get openwebrx/admin_user_password
|
db_get openwebrx/admin_user_password
|
||||||
if [ ! -z "${RET}" ]; then
|
if [ ! -z "${RET}" ]; then
|
||||||
if ! openwebrx admin --silent hasuser admin; then
|
if ! openwebrx admin --silent hasuser admin; then
|
||||||
|
@ -83,9 +83,10 @@ class Bookmarks(object):
|
|||||||
def _loadBookmarks(self):
|
def _loadBookmarks(self):
|
||||||
for file in self.fileList:
|
for file in self.fileList:
|
||||||
try:
|
try:
|
||||||
f = open(file, "r")
|
with open(file, "r") as f:
|
||||||
bookmarks_json = json.load(f)
|
content = f.read()
|
||||||
f.close()
|
if content:
|
||||||
|
bookmarks_json = json.loads(content)
|
||||||
return [Bookmark(d) for d in bookmarks_json]
|
return [Bookmark(d) for d in bookmarks_json]
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user