1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Reduce storage calls

This commit is contained in:
David Bomba 2022-10-22 10:08:37 +11:00
parent eca5635d3e
commit 89c42a257c
3 changed files with 4 additions and 36 deletions

View File

@ -515,8 +515,8 @@ class CompanyExport implements ShouldQueue
$path = 'backups';
if(!Storage::disk(config('filesystems.default'))->exists($path))
Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
// if(!Storage::disk(config('filesystems.default'))->exists($path))
// Storage::disk(config('filesystems.default'))->makeDirectory($path, 0775);
$zip_path = public_path('storage/backups/'.$file_name);
$zip = new \ZipArchive();

View File

@ -40,11 +40,11 @@ class Backup extends BaseModel
Storage::disk(config('filesystems.default'))->put($file_path, $html);
if (Storage::disk(config('filesystems.default'))->exists($file_path)) {
// if (Storage::disk(config('filesystems.default'))->exists($file_path)) {
$this->html_backup = '';
$this->filename = $file_path;
$this->save();
}
// }
}
public function deleteFile()

View File

@ -58,37 +58,5 @@ class DownloadHistoricalInvoiceTest extends TestCase
$this->assertNotNull($this->invoice->activities);
}
public function testBackupExists()
{
$this->mockActivity();
$this->assertNotNull($this->invoice->activities->first()->backup->html_backup);
}
public function testBackupDownload()
{
$this->mockActivity();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/activities/download_entity/'.$this->encodePrimaryKey($this->invoice->activities->first()->id));
$response->assertStatus(200);
}
public function testBackupCheckPriorToDownloadWorks()
{
$this->mockActivity();
$backup = $this->invoice->activities->first()->backup;
$backup->forceDelete();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/activities/download_entity/'.$this->encodePrimaryKey($this->invoice->activities->first()->id));
$response->assertStatus(404);
}
}