Ajax
10 months ago
BackgroundProcessing
1 year ago
Dto
10 months ago
Entity
10 months ago
Exceptions
1 year ago
Interfaces
1 year ago
Job
10 months ago
Request
1 year ago
Service
10 months ago
Storage
11 months ago
Task
10 months ago
Traits
10 months ago
AfterRestore.php
1 year ago
BackupDeleter.php
1 year ago
BackupDownload.php
1 year ago
BackupFileIndex.php
1 year ago
BackupGlitchReason.php
1 year ago
BackupHeader.php
10 months ago
BackupRepairer.php
1 year ago
BackupRetentionHandler.php
1 year ago
BackupScheduler.php
11 months ago
BackupServiceProvider.php
10 months ago
BackupValidator.php
1 year ago
FileHeader.php
10 months ago
FileHeaderAttribute.php
2 years ago
WithBackupIdentifier.php
1 year ago
BackupDownload.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup; |
| 4 | |
| 5 | use WPStaging\Core\WPStaging; |
| 6 | use WPStaging\Framework\Adapter\Directory; |
| 7 | |
| 8 | class BackupDownload |
| 9 | { |
| 10 | /** |
| 11 | * @return void |
| 12 | */ |
| 13 | public function deleteUnfinishedDownloads() |
| 14 | { |
| 15 | $dir = WPStaging::make(Directory::class)->getDownloadsDirectory(); |
| 16 | if (!is_dir($dir)) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | $extension = ".wpstg"; // Extension of the file created when download starts. |
| 21 | if ($dh = opendir($dir)) { |
| 22 | while (($file = readdir($dh)) !== false) { |
| 23 | if (strpos($file, $extension) !== false) { |
| 24 | unlink($dir . '/' . $file); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | closedir($dh); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 |