CC-3230: Show appropriate error message if disk is full when attempting to upload files via the web UI
- moved the logic used to test that the destination folder has enought space to copy the given audio file into.
This commit is contained in:
parent
e07ad45b1a
commit
9fc0ed198e
|
@ -842,6 +842,22 @@ class Application_Model_StoredFile {
|
||||||
return $tempFilePath;
|
return $tempFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check, using disk_free_space, the space available in the $destination_folder folder to see if it has
|
||||||
|
* enough space to move the $audio_file into and report back to the user if not.
|
||||||
|
**/
|
||||||
|
public static function checkForEnoughDiskSpaceToCopy($destination_folder, $audio_file){
|
||||||
|
//check to see if we have enough space in the /organize directory to copy the file
|
||||||
|
$freeSpace = disk_free_space($destination_folder);
|
||||||
|
$fileSize = filesize($audio_file);
|
||||||
|
|
||||||
|
if ( $freeSpace < $fileSize ){
|
||||||
|
$freeSpace = floor($freeSpace/1024/1024);
|
||||||
|
$fileSize = floor($fileSize/1024/1024);
|
||||||
|
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "The file was not uploaded, there was '.$freeSpace.'MB disk space left the file you are uploadings size is '.$fileSize.'MB."}}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function copyFileToStor($p_targetDir, $fileName, $tempname){
|
public static function copyFileToStor($p_targetDir, $fileName, $tempname){
|
||||||
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
|
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
|
||||||
Logging::log('copyFileToStor: moving file '.$audio_file);
|
Logging::log('copyFileToStor: moving file '.$audio_file);
|
||||||
|
@ -860,14 +876,8 @@ class Application_Model_StoredFile {
|
||||||
$storDir = Application_Model_MusicDir::getStorDir();
|
$storDir = Application_Model_MusicDir::getStorDir();
|
||||||
$stor = $storDir->getDirectory();
|
$stor = $storDir->getDirectory();
|
||||||
|
|
||||||
//check to see if we have enough space in the /organize directory to copy the file
|
//check to see if there is enough space in $stor to continue.
|
||||||
$freeSpace = disk_free_space($stor);
|
Application_Model_StoredFile::checkForEnoughDiskSpaceToCopy($stor, $audio_file);
|
||||||
$fileSize = filesize($audio_file);
|
|
||||||
if ( $freeSpace < $fileSize ){
|
|
||||||
$freeSpace = floor($freeSpace/1024/1024);
|
|
||||||
$fileSize = floor($fileSize/1024/1024);
|
|
||||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "The file was not uploaded, there was '.$freeSpace.'MB disk space left the file you are uploadings size is '.$fileSize.'MB."}}');
|
|
||||||
}
|
|
||||||
|
|
||||||
$stor .= "/organize";
|
$stor .= "/organize";
|
||||||
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
|
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
|
||||||
|
@ -887,6 +897,7 @@ class Application_Model_StoredFile {
|
||||||
//$r = @unlink($audio_file);
|
//$r = @unlink($audio_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getFileCount()
|
public static function getFileCount()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
Loading…
Reference in New Issue