sync script added and fixed some controllers

This commit is contained in:
Chris
2020-01-07 22:13:29 +01:00
parent 63fe1b3edd
commit a19d0a3d48
5 changed files with 149 additions and 86 deletions

View File

@@ -13,6 +13,20 @@ class AltfolderStorage implements StorageController
return file_exists($altname);
}
function getItems()
{
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ALT_FOLDER.DS));
$files = array();
foreach ($rii as $file) {
if ($file->isDir())
continue;
$files[] = $file->getPathname();
}
return $files;
}
function pullFile($hash,$location)
{
$altname=ALT_FOLDER.DS.$hash;
@@ -25,8 +39,7 @@ class AltfolderStorage implements StorageController
function pushFile($source,$hash)
{
$altname=ALT_FOLDER.DS.$hash;
$orig = ROOT.DS.'data'.DS.$hash.DS.$hash;
if(file_exists($orig) && !$this->hashExists($hash))
if(!$this->hashExists($hash))
{
copy($source,$altname);
return true;

View File

@@ -36,7 +36,23 @@ class S3Storage implements StorageController
if(!$this->s3)$this->connect();
return $this->s3->doesObjectExist(S3_BUCKET,$hash);
}
}
function getItems()
{
if(!$this->s3)$this->connect();
$iterator = $this->s3->getIterator('ListObjects', [
'Bucket' => S3_BUCKET
]);
$items = array();
foreach ($iterator as $object) {
$items[] = $object['Key'];
}
return $items;
}
function pullFile($hash,$location)
{