mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-16 13:08:01 +00:00
allow skipping of phase 1
This commit is contained in:
@@ -43,49 +43,51 @@ if(defined('ENCRYPTION_KEY') && ENCRYPTION_KEY)
|
|||||||
echo "[i] Encryption key found. Will encrypt on Storage controllers\n";
|
echo "[i] Encryption key found. Will encrypt on Storage controllers\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!in_array('p2',$argv))
|
||||||
echo "[i] PHASE 1\n";
|
|
||||||
echo " [P1] Files from Storage controllers will be downloaded if they don't exist localy\n";
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
foreach($controllers as $contr)
|
|
||||||
{
|
{
|
||||||
echo " [P1] Collecting list of items from ".get_class($contr)."..";
|
echo "[i] PHASE 1\n";
|
||||||
$controllerfiles = $contr->getItems(true);
|
echo " [P1] Files from Storage controllers will be downloaded if they don't exist localy\n";
|
||||||
echo " done. Got ".count($controllerfiles)." files\n";
|
sleep(1);
|
||||||
if($controllerfiles)
|
|
||||||
foreach($controllerfiles as $cfile)
|
foreach($controllers as $contr)
|
||||||
{
|
{
|
||||||
if(endswith($cfile,'.enc'))
|
echo " [P1] Collecting list of items from ".get_class($contr)."..";
|
||||||
$hash = substr($cfile,0,-4);
|
$controllerfiles = $contr->getItems(true);
|
||||||
else $hash = $cfile;
|
echo " done. Got ".count($controllerfiles)." files\n";
|
||||||
if(!is_dir($dir.$hash) || !file_exists($dir.$hash.DS.$hash)) //file only on storage controller. Will download
|
if($controllerfiles)
|
||||||
|
foreach($controllerfiles as $cfile)
|
||||||
{
|
{
|
||||||
echo " [P1] $hash is not on the Server but on ".get_class($contr)."\n";
|
if(endswith($cfile,'.enc'))
|
||||||
if($enc && endswith($cfile,'.enc')) // if its encrypted and we can decrypt, then do it
|
$hash = substr($cfile,0,-4);
|
||||||
|
else $hash = $cfile;
|
||||||
|
if(!is_dir($dir.$hash) || !file_exists($dir.$hash.DS.$hash)) //file only on storage controller. Will download
|
||||||
{
|
{
|
||||||
if($sim!==true)
|
echo " [P1] $hash is not on the Server but on ".get_class($contr)."\n";
|
||||||
|
if($enc && endswith($cfile,'.enc')) // if its encrypted and we can decrypt, then do it
|
||||||
{
|
{
|
||||||
$contr->pullFile($cfile,ROOT.DS.'tmp'.DS.$cfile);
|
if($sim!==true)
|
||||||
$enc->decryptFile(ROOT.DS.'tmp'.DS.$cfile, ROOT.DS.'tmp'.DS.$hash,base64_decode(ENCRYPTION_KEY));
|
{
|
||||||
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
|
$contr->pullFile($cfile,ROOT.DS.'tmp'.DS.$cfile);
|
||||||
unlink(ROOT.DS.'tmp'.DS.$cfile);
|
$enc->decryptFile(ROOT.DS.'tmp'.DS.$cfile, ROOT.DS.'tmp'.DS.$hash,base64_decode(ENCRYPTION_KEY));
|
||||||
|
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
|
||||||
|
unlink(ROOT.DS.'tmp'.DS.$cfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else{ //otherwise just get the file
|
||||||
else{ //otherwise just get the file
|
if($sim!==true){
|
||||||
if($sim!==true){
|
$contr->pullFile($hash,ROOT.DS.'tmp'.DS.$hash);
|
||||||
$contr->pullFile($hash,ROOT.DS.'tmp'.DS.$hash);
|
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
|
||||||
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo "\n ----------- END OF PHASE 1 -----------\n\n";
|
||||||
}
|
}
|
||||||
|
else echo "[i] Skipping Phase 1\n";
|
||||||
|
|
||||||
echo "\n ----------- END OF PHASE 1 -----------\n\n";
|
|
||||||
|
|
||||||
|
|
||||||
echo "[i] PHASE 2\n";
|
echo "[i] PHASE 2\n";
|
||||||
echo " [P2] Local files are synced to all storage controllers\n";
|
echo " [P2] Local files are synced to all storage controllers\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user