diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 77aaddb59..1f2f4f965 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -487,9 +487,11 @@ flashupdate.squashfs.noversion Bei Updates werden Versionsüberprüfungen derzei flashupdate.titlereadflash Flash auslesen flashupdate.titlewriteflash Flash schreiben flashupdate.update_with_settings_del_skipped Ordner [%s] kann nicht gelöscht werden. Eintrag wird übersprungen. +flashupdate.update_with_settings_error Error Flashspeicher!\n \nIm neuen Image sind nur noch %ld KB (von %ld KB) frei,\ndas ist zu wenig, um einen sicheren Betrieb zu gewährleisten.\n \nDer Vorgang wird abgebrochen! flashupdate.update_with_settings_processed Image wird bearbeitet... flashupdate.update_with_settings_skipped Ordner [%s] kann nicht gesichert werden. Eintrag wird übersprungen. flashupdate.update_with_settings_successfully Settingsübernahme erfolgreich.\nDas Image kann jetzt geflasht werden. +flashupdate.update_with_settings_warning Warnung Flashspeicher!\n \nIm neuen Image sind nur noch %ld KB (von %ld KB) frei,\ndas ist möglicherweise zu wenig, um einen sicheren Betrieb zu gewährleisten.\n \nSoll der Vorgang trotzdem fortgesetzt werden? flashupdate.updatemode Updatemodus flashupdate.updatemode_internet Internet flashupdate.updatemode_manual von lokalem Update-Verzeichnis diff --git a/data/locale/english.locale b/data/locale/english.locale index 472b88de4..222ab4da6 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -487,9 +487,11 @@ flashupdate.squashfs.noversion SquashFS version checks are currently only suppor flashupdate.titlereadflash Reading Flash flashupdate.titlewriteflash Writing Flash flashupdate.update_with_settings_del_skipped Folder [%s] can not be deleted. Entry is skipped. +flashupdate.update_with_settings_error Flash Error!\n \nNew Image only has %ld KB (out of %ld KB) left. Not\nenough space to complete this operation.\n \nCanceling operation! flashupdate.update_with_settings_processed Image is being processed... flashupdate.update_with_settings_skipped Folder [%s] can not be saved. Entry is skipped. flashupdate.update_with_settings_successfully Setting takeover successfully.\nThe image can now be flashed. +flashupdate.update_with_settings_warning Flash Warning!\n \nNew Image only has %ld KB (out of %ld KB) left. Probably not\nenough space to complete this operation...\n \nDo you really want to proceed? flashupdate.updatemode Updatemode flashupdate.updatemode_internet internet flashupdate.updatemode_manual from local update directory diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index c9094941d..4c4ffe169 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -5,7 +5,7 @@ and some other guys Homepage: http://dbox.cyberphoria.org/ - Copyright (C) 2012 M. Liebmann (micha-bbg) + Copyright (C) 2012-2013 M. Liebmann (micha-bbg) License: GPL @@ -73,6 +73,10 @@ CExtUpdate::CExtUpdate() fLogfile = "/tmp/update.log"; mountPkt = "/tmp/image_mount"; FileHelpers = NULL; + flashErrorFlag = false; + total = bsize = used = 0; + free1 = free2 = free3 = 0; + copyList.clear(); blackList.clear(); deleteList.clear(); @@ -147,7 +151,7 @@ bool CExtUpdate::applySettings(const std::string & filename, int mode) bool ret = applySettings(); DBG_TIMER_STOP("Image editing") if (!ret) { - if (mtdRamError != "") + if ((mtdRamError != "") && (!flashErrorFlag)) DisplayErrorMessage(mtdRamError.c_str()); // error, restore original file @@ -309,8 +313,14 @@ bool CExtUpdate::applySettings() if (res) return ErrorReset(RESET_UNLOAD, "mount error"); - if (!readBackupList(mountPkt)) + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) + free1 = (total * bsize) / 1024 - (used * bsize) / 1024; + + if (!readBackupList(mountPkt)) { + if (flashErrorFlag) + return false; return ErrorReset(0, "error readBackupList"); + } res = umount(mountPkt.c_str()); if (res) @@ -606,6 +616,9 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } sync(); + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) + free2 = (total * bsize) / 1024 - (used * bsize) / 1024; + // read copyList for(it = copyList.begin(); it != copyList.end(); ++it) { line = *it; @@ -652,6 +665,29 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } } sync(); + + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) { + long flashWarning = 1000; // 1MB + long flashError = 600; // 600KB + char buf1[1024]; + total = (total * bsize) / 1024; + free3 = total - (used * bsize) / 1024; + printf("##### [%s] %ld KB free org, %ld KB free after delete, %ld KB free now\n", __FUNCTION__, free1, free2, free3); + memset(buf1, '\0', sizeof(buf1)); + if (free3 <= flashError) { + snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); + ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); + flashErrorFlag = true; + return false; + } + else if (free3 <= flashWarning) { + snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total); + if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { + flashErrorFlag = true; + return false; + } + } + } return true; } diff --git a/src/gui/ext_update.h b/src/gui/ext_update.h index e0291641b..2999c9fa2 100644 --- a/src/gui/ext_update.h +++ b/src/gui/ext_update.h @@ -5,7 +5,7 @@ and some other guys Homepage: http://dbox.cyberphoria.org/ - Copyright (C) 2012 M. Liebmann (micha-bbg) + Copyright (C) 2012-2013 M. Liebmann (micha-bbg) License: GPL @@ -56,6 +56,10 @@ class CExtUpdate CFileHelpers* FileHelpers; std::vector copyList, blackList, deleteList; + bool flashErrorFlag; + long total, bsize, used; + long free1, free2, free3; + bool applySettings(void); bool readBackupList(const std::string & dstPath); bool copyFileList(const std::string & fileList, const std::string & dstPath); diff --git a/src/system/locals.h b/src/system/locals.h index 9d670a45b..19f72a907 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -514,9 +514,11 @@ typedef enum LOCALE_FLASHUPDATE_TITLEREADFLASH, LOCALE_FLASHUPDATE_TITLEWRITEFLASH, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED, + LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY, + LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING, LOCALE_FLASHUPDATE_UPDATEMODE, LOCALE_FLASHUPDATE_UPDATEMODE_INTERNET, LOCALE_FLASHUPDATE_UPDATEMODE_MANUAL, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index e00f7b242..bebeabfbb 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -514,9 +514,11 @@ const char * locale_real_names[] = "flashupdate.titlereadflash", "flashupdate.titlewriteflash", "flashupdate.update_with_settings_del_skipped", + "flashupdate.update_with_settings_error", "flashupdate.update_with_settings_processed", "flashupdate.update_with_settings_skipped", "flashupdate.update_with_settings_successfully", + "flashupdate.update_with_settings_warning", "flashupdate.updatemode", "flashupdate.updatemode_internet", "flashupdate.updatemode_manual",