mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 02:41:12 +02:00
Softupdate: Check the available space before copy image to /tmp on apollo
Origin commit data
------------------
Branch: ni/coolstream
Commit: 8a5c32d0f6
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-08-21 (Wed, 21 Aug 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -173,7 +173,25 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
|||||||
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
|
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
|
||||||
char* dn = dirname(buf1);
|
char* dn = dirname(buf1);
|
||||||
std::string flashfile;
|
std::string flashfile;
|
||||||
|
|
||||||
|
bool skipCopy = false;
|
||||||
|
#ifdef BOXMODEL_APOLLO
|
||||||
if (strcmp(dn, "/tmp") != 0) {
|
if (strcmp(dn, "/tmp") != 0) {
|
||||||
|
long btotal = 0, bused = 0, bsize = 0;
|
||||||
|
if (get_fs_usage("/tmp", btotal, bused, &bsize)) {
|
||||||
|
int fileSize = file_size(filename.c_str()) / 1024;
|
||||||
|
int backupMaxSize = (int)((btotal - bused) * bsize);
|
||||||
|
int res = 10; // Reserved 10% of available space
|
||||||
|
backupMaxSize = (backupMaxSize - ((backupMaxSize * res) / 100)) / 1024;
|
||||||
|
if (backupMaxSize < fileSize)
|
||||||
|
skipCopy = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skipCopy = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((strcmp(dn, "/tmp") != 0) && !skipCopy) {
|
||||||
memset(buf1, 0, sizeof(buf1));
|
memset(buf1, 0, sizeof(buf1));
|
||||||
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
|
strncpy(buf1, filename.c_str(), sizeof(buf1)-1);
|
||||||
flashfile = (std::string)"/tmp/" + basename(buf1);
|
flashfile = (std::string)"/tmp/" + basename(buf1);
|
||||||
@@ -190,8 +208,10 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra
|
|||||||
flashfile = filename;
|
flashfile = filename;
|
||||||
|
|
||||||
// Unmount all NFS & CIFS volumes
|
// Unmount all NFS & CIFS volumes
|
||||||
nfs_mounted_once = false;
|
if (!skipCopy) {
|
||||||
CFSMounter::umount();
|
nfs_mounted_once = false;
|
||||||
|
CFSMounter::umount();
|
||||||
|
}
|
||||||
|
|
||||||
if( (fd1 = open( flashfile.c_str(), O_RDONLY )) < 0 ) {
|
if( (fd1 = open( flashfile.c_str(), O_RDONLY )) < 0 ) {
|
||||||
ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE);
|
ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE);
|
||||||
|
Reference in New Issue
Block a user