Add backups size to pop-up dialog (#1453)

This commit is contained in:
Veronica Berglyd Olsen
2023-07-27 00:09:05 +02:00
parent d81a90add3
commit ace037808f
2 changed files with 5 additions and 5 deletions
+1 -2
View File
@@ -209,8 +209,7 @@ def checkIntTuple(value: int, valid: tuple | list | set, default: int) -> int:
# =============================================================================================== # # =============================================================================================== #
def formatInt(value: int) -> str: def formatInt(value: int) -> str:
"""Formats an integer with k, M, G etc. """Formats an integer with k, M, G etc."""
"""
if not isinstance(value, int): if not isinstance(value, int):
return "ERR" return "ERR"
+4 -3
View File
@@ -46,7 +46,7 @@ from novelwriter.core.sessions import NWSessionLog
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
from novelwriter.core.projectdata import NWProjectData from novelwriter.core.projectdata import NWProjectData
from novelwriter.common import ( from novelwriter.common import (
checkStringNone, formatTimeStamp, hexToInt, makeFileNameSafe, minmax checkStringNone, formatInt, formatTimeStamp, hexToInt, makeFileNameSafe, minmax
) )
if TYPE_CHECKING: # pragma: no cover if TYPE_CHECKING: # pragma: no cover
@@ -449,10 +449,11 @@ class NWProject(QObject):
timeStamp = formatTimeStamp(time(), fileSafe=True) timeStamp = formatTimeStamp(time(), fileSafe=True)
archName = baseDir / f"{cleanName} {timeStamp}.zip" archName = baseDir / f"{cleanName} {timeStamp}.zip"
if self._storage.zipIt(archName, compression=2): if self._storage.zipIt(archName, compression=2):
size = archName.stat().st_size
if doNotify: if doNotify:
self.mainGui.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Backup archive file written to: {0}" "Backup archive file written to: {0} [{1}B]"
).format(str(archName), nwAlert.INFO)) ).format(str(archName), formatInt(size)), nwAlert.INFO)
else: else:
self.mainGui.makeAlert(self.tr( self.mainGui.makeAlert(self.tr(
"Could not write backup archive." "Could not write backup archive."