SAAS-525: Station Termination -> Delete cloud_file table records
Deleted cloud_file records. Renamed the function that does this.
This commit is contained in:
parent
09c30bde1b
commit
ab4ebb2969
|
@ -59,46 +59,19 @@ class Amazon_S3 extends StorageBackend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteObjects()
|
public function deleteAllCloudFileObjects()
|
||||||
{
|
{
|
||||||
$cloudFilePager = CloudFileQuery::create()
|
$this->s3Client->deleteMatchingObjects(
|
||||||
->filterByStorageBackend("amazon_S3")
|
$bucket = $this->getBucket(),
|
||||||
->paginate($page=1, $maxPerPage=1000);
|
$prefix = Application_Model_Preference::GetStationName());
|
||||||
|
|
||||||
if ($cloudFilePager->haveToPaginate()) {
|
|
||||||
$numPages = $cloudFilePager->getLastPage();
|
|
||||||
$currentPage = 1;
|
|
||||||
while ($currentPage <= $numPages) {
|
|
||||||
$cloudFilePager = CloudFileQuery::create()
|
|
||||||
->filterByStorageBackend("amazon_S3")
|
|
||||||
->paginate($page = $currentPage, $maxPerPage = 1000);
|
|
||||||
|
|
||||||
$this->deleteObjectSet($cloudFilePager->getResults());
|
// delete record of the cloud files from the database
|
||||||
|
$criteria = new Criteria();
|
||||||
$currentPage += 1;
|
$criteria->clearSelectColumns();
|
||||||
}
|
$criteria->addSelectColumn(CloudFilePeer::CC_FILE_ID);
|
||||||
} else {
|
$results = CloudFilePeer::doSelectStmt($criteria)->fetchAll();
|
||||||
$this->deleteObjectSet($cloudFilePager->getResults());
|
foreach ($results as $key => $value) {
|
||||||
}
|
CcFilesQuery::create()->findPk($value["cc_file_id"])->delete();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes objects from Amazon S3 1000 at a time.
|
|
||||||
* 1000 is the max number of objects that can be deleted using the aws sdk
|
|
||||||
* api, per request.
|
|
||||||
*/
|
|
||||||
private function deleteObjectSet($cloudFiles)
|
|
||||||
{
|
|
||||||
if (!$cloudFiles->isEmpty()) {
|
|
||||||
$cloudFilesToDelete = array();
|
|
||||||
|
|
||||||
foreach ($cloudFiles as $cloudFile) {
|
|
||||||
array_push($cloudFilesToDelete, array("Key" => $cloudFile->getResourceId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->s3Client->deleteObjects(array(
|
|
||||||
"Bucket" => $this->getBucket(),
|
|
||||||
"Objects" => $cloudFilesToDelete));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,9 @@ class ProxyStorageBackend extends StorageBackend
|
||||||
$this->storageBackend->deletePhysicalFile($resourceId);
|
$this->storageBackend->deletePhysicalFile($resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteObjects()
|
public function deleteAllCloudFileObjects()
|
||||||
{
|
{
|
||||||
$this->storageBackend->deleteObjects();
|
$this->storageBackend->deleteAllCloudFileObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,9 @@ abstract class StorageBackend
|
||||||
/** Deletes the file from the storage backend. */
|
/** Deletes the file from the storage backend. */
|
||||||
abstract public function deletePhysicalFile($resourceId);
|
abstract public function deletePhysicalFile($resourceId);
|
||||||
|
|
||||||
/** Deletes multiple objects (files) stored on the cloud service. */
|
/** Deletes all objects (files) stored on the cloud service. To be used
|
||||||
abstract public function deleteObjects();
|
* for station termination */
|
||||||
|
abstract public function deleteAllCloudFileObjects();
|
||||||
|
|
||||||
protected function getBucket()
|
protected function getBucket()
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ProvisioningController extends Zend_Controller_Action
|
||||||
|
|
||||||
foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) {
|
foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) {
|
||||||
$proxyStorageBackend = new ProxyStorageBackend($storageBackend);
|
$proxyStorageBackend = new ProxyStorageBackend($storageBackend);
|
||||||
$proxyStorageBackend->deleteObjects();
|
$proxyStorageBackend->deleteAllCloudFileObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check at to make sure cloud_file table is empty
|
//check at to make sure cloud_file table is empty
|
||||||
|
|
Loading…
Reference in New Issue