summaryrefslogtreecommitdiff
path: root/src/Manager
diff options
context:
space:
mode:
authorKhaled Lela <eng.khaled.lela@gmail.com>2025-08-14 14:41:34 +0300
committerKhaled Lela <eng.khaled.lela@gmail.com>2025-08-14 14:41:34 +0300
commite43bcd1830be760ee2b05c559c661710d107d826 (patch)
tree50f11d02d2d6807cf6396a448ea73624f83d4512 /src/Manager
parent6d56f9625112864828511b52250e2a014736039c (diff)
Refactor SCORM disk handling by removing redundant disk accessibility checks and cleaning up whitespace. This improves code readability and maintains existing functionality.
Diffstat (limited to 'src/Manager')
-rw-r--r--src/Manager/ScormDisk.php38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/Manager/ScormDisk.php b/src/Manager/ScormDisk.php
index 47fd3eb..5b71904 100644
--- a/src/Manager/ScormDisk.php
+++ b/src/Manager/ScormDisk.php
@@ -48,27 +48,27 @@ class ScormDisk
{
try {
$archiveDisk = $this->getArchiveDisk();
-
+
// Log the file path being processed for debugging
Log::info('Processing SCORM archive file: ' . $file);
-
+
// Check if file exists on archive disk
if (!$archiveDisk->exists($file)) {
Log::error('File not found on archive disk: ' . $file);
throw new StorageNotFoundException('scorm_archive_not_found_on_archive_disk: ' . $file);
}
-
+
// Get the stream from archive disk
$stream = $archiveDisk->readStream($file);
if (!is_resource($stream)) {
Log::error('Failed to read stream from archive disk for file: ' . $file . '. Stream type: ' . gettype($stream));
throw new StorageNotFoundException('failed_to_read_scorm_archive_stream: ' . $file);
}
-
+
if (Storage::exists($file)) {
Storage::delete($file);
}
-
+
Storage::writeStream($file, $stream);
$path = Storage::path($file);
call_user_func($fn, $path);
@@ -155,21 +155,13 @@ class ScormDisk
if (empty($diskName)) {
throw new StorageNotFoundException('scorm_disk_not_configured');
}
-
+
if (!config()->has('filesystems.disks.' . $diskName)) {
throw new StorageNotFoundException('scorm_disk_not_define: ' . $diskName);
}
-
+
$disk = Storage::disk($diskName);
-
- // Test if the disk is accessible
- try {
- $disk->exists('test');
- } catch (Exception $ex) {
- Log::error('SCORM disk not accessible: ' . $ex->getMessage());
- throw new StorageNotFoundException('scorm_disk_not_accessible: ' . $diskName);
- }
-
+
return $disk;
}
@@ -182,21 +174,13 @@ class ScormDisk
if (empty($archiveDiskName)) {
throw new StorageNotFoundException('scorm_archive_disk_not_configured');
}
-
+
if (!config()->has('filesystems.disks.' . $archiveDiskName)) {
throw new StorageNotFoundException('scorm_archive_disk_not_define: ' . $archiveDiskName);
}
-
+
$disk = Storage::disk($archiveDiskName);
-
- // Test if the disk is accessible
- try {
- $disk->exists('test');
- } catch (Exception $ex) {
- Log::error('Archive disk not accessible: ' . $ex->getMessage());
- throw new StorageNotFoundException('scorm_archive_disk_not_accessible: ' . $archiveDiskName);
- }
-
+
return $disk;
}
}