mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
Softupdate: Check the available disk space when reading the flash
This commit is contained in:
@@ -509,6 +509,9 @@ flashupdate.proxyserver_sep Proxyserver
|
|||||||
flashupdate.proxyusername Benutzername
|
flashupdate.proxyusername Benutzername
|
||||||
flashupdate.proxyusername_hint1 Geben Sie den Proxy-Benutzernamen ein
|
flashupdate.proxyusername_hint1 Geben Sie den Proxy-Benutzernamen ein
|
||||||
flashupdate.proxyusername_hint2 Ein leerer Eintrag bedeutet keine Authentifizierung
|
flashupdate.proxyusername_hint2 Ein leerer Eintrag bedeutet keine Authentifizierung
|
||||||
|
flashupdate.read_directory_not_exist Das Backupverzeichnis %s \nexistiert nicht!
|
||||||
|
flashupdate.read_no_available_space Der maximal verfügbare Platz in %s \nbeträgt %d KB, es werden aber %d KB benötigt.\n \nDer Vorgang wird abgebrochen, wählen sie bitte einen anderen Datenträger!
|
||||||
|
flashupdate.read_volume_error Die Größe des Datenträgers %s \nkann nicht ermittelt werden!
|
||||||
flashupdate.readflash ganzes Flashimage auslesen
|
flashupdate.readflash ganzes Flashimage auslesen
|
||||||
flashupdate.readflashmtd einzelne Partition auslesen
|
flashupdate.readflashmtd einzelne Partition auslesen
|
||||||
flashupdate.ready fertig
|
flashupdate.ready fertig
|
||||||
|
@@ -509,6 +509,9 @@ flashupdate.proxyserver_sep Proxyserver
|
|||||||
flashupdate.proxyusername Username
|
flashupdate.proxyusername Username
|
||||||
flashupdate.proxyusername_hint1 enter the proxyserver username
|
flashupdate.proxyusername_hint1 enter the proxyserver username
|
||||||
flashupdate.proxyusername_hint2 a empty entry means no proxy-auth
|
flashupdate.proxyusername_hint2 a empty entry means no proxy-auth
|
||||||
|
flashupdate.read_directory_not_exist The backup directory %s \ndoes not exist!
|
||||||
|
flashupdate.read_no_available_space The maximum available space in %s \nis %d KB, but there are %d KB required.\n \nThe operation is canceled, please choose another medium!
|
||||||
|
flashupdate.read_volume_error The size of the volume %s \ncan not be determined!
|
||||||
flashupdate.readflash Read whole image
|
flashupdate.readflash Read whole image
|
||||||
flashupdate.readflashmtd Read one partition
|
flashupdate.readflashmtd Read one partition
|
||||||
flashupdate.ready ready
|
flashupdate.ready ready
|
||||||
|
@@ -550,6 +550,36 @@ CFlashExpert* CFlashExpert::getInstance()
|
|||||||
return FlashExpert;
|
return FlashExpert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFlashExpert::checkSize(int mtd, std::string &backupFile)
|
||||||
|
{
|
||||||
|
char errMsg[1024] = {0};
|
||||||
|
std::string path = getPathName(backupFile);
|
||||||
|
if (!file_exists(path.c_str())) {
|
||||||
|
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), path.c_str());
|
||||||
|
ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mtdSize = CMTDInfo::getInstance()->getMTDSize(mtd) / 1024;
|
||||||
|
|
||||||
|
long btotal = 0, bused = 0, bsize = 0;
|
||||||
|
if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) {
|
||||||
|
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str());
|
||||||
|
ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int backupMaxSize = (int)((btotal - bused) * bsize);
|
||||||
|
int res = 10; // Reserved 10% of available space
|
||||||
|
backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100)) / 1024;
|
||||||
|
if (backupMaxSize < mtdSize) {
|
||||||
|
snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), backupMaxSize, mtdSize);
|
||||||
|
ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CFlashExpert::readmtd(int preadmtd)
|
void CFlashExpert::readmtd(int preadmtd)
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string filename;
|
||||||
@@ -566,6 +596,10 @@ void CFlashExpert::readmtd(int preadmtd)
|
|||||||
filename = (std::string)g_settings.update_dir + "/flashimage.img"; // US-ASCII (subset of UTF-8 and ISO8859-1)
|
filename = (std::string)g_settings.update_dir + "/flashimage.img"; // US-ASCII (subset of UTF-8 and ISO8859-1)
|
||||||
preadmtd = MTD_OF_WHOLE_IMAGE;
|
preadmtd = MTD_OF_WHOLE_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkSize(preadmtd, filename))
|
||||||
|
return;
|
||||||
|
|
||||||
setTitle(LOCALE_FLASHUPDATE_TITLEREADFLASH);
|
setTitle(LOCALE_FLASHUPDATE_TITLEREADFLASH);
|
||||||
paint();
|
paint();
|
||||||
showGlobalStatus(0);
|
showGlobalStatus(0);
|
||||||
|
@@ -75,6 +75,7 @@ class CFlashExpert : public CProgressWindow
|
|||||||
void showMTDSelector(const std::string & actionkey);
|
void showMTDSelector(const std::string & actionkey);
|
||||||
void showFileSelector(const std::string & actionkey);
|
void showFileSelector(const std::string & actionkey);
|
||||||
|
|
||||||
|
bool checkSize(int mtd, std::string &backupFile);
|
||||||
void readmtd(int readmtd);
|
void readmtd(int readmtd);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -536,6 +536,9 @@ typedef enum
|
|||||||
LOCALE_FLASHUPDATE_PROXYUSERNAME,
|
LOCALE_FLASHUPDATE_PROXYUSERNAME,
|
||||||
LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1,
|
LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1,
|
||||||
LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2,
|
LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2,
|
||||||
|
LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST,
|
||||||
|
LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE,
|
||||||
|
LOCALE_FLASHUPDATE_READ_VOLUME_ERROR,
|
||||||
LOCALE_FLASHUPDATE_READFLASH,
|
LOCALE_FLASHUPDATE_READFLASH,
|
||||||
LOCALE_FLASHUPDATE_READFLASHMTD,
|
LOCALE_FLASHUPDATE_READFLASHMTD,
|
||||||
LOCALE_FLASHUPDATE_READY,
|
LOCALE_FLASHUPDATE_READY,
|
||||||
|
@@ -536,6 +536,9 @@ const char * locale_real_names[] =
|
|||||||
"flashupdate.proxyusername",
|
"flashupdate.proxyusername",
|
||||||
"flashupdate.proxyusername_hint1",
|
"flashupdate.proxyusername_hint1",
|
||||||
"flashupdate.proxyusername_hint2",
|
"flashupdate.proxyusername_hint2",
|
||||||
|
"flashupdate.read_directory_not_exist",
|
||||||
|
"flashupdate.read_no_available_space",
|
||||||
|
"flashupdate.read_volume_error",
|
||||||
"flashupdate.readflash",
|
"flashupdate.readflash",
|
||||||
"flashupdate.readflashmtd",
|
"flashupdate.readflashmtd",
|
||||||
"flashupdate.ready",
|
"flashupdate.ready",
|
||||||
|
Reference in New Issue
Block a user