Skip to content

Commit 5401611

Browse files
committed
fix: delete media upload
1 parent f9b281d commit 5401611

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

app/Services/FileSystem/AbstractFileUploadStrategy.php

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,28 @@ public function saveFromStream($fp, string $path, $options = []):bool{
6363
*/
6464
public function markAsDeleted(string $path, ?string $filename = null)
6565
{
66-
Log::debug(sprintf("AbstractFileUploadStrategy:: markAsDeleted path %s filename %s", $path, $filename));
67-
$from = empty($filename) ? $path : sprintf("%s/%s", $path, $filename);
68-
$to = null;
69-
if(empty($filename)){
70-
$parts = explode("/", $path);
71-
$parts[count($parts) - 1] = sprintf("DELETED_%s", $parts[count($parts) - 1] );
72-
$to = implode("/", $parts);
66+
try{
67+
Log::debug(sprintf("AbstractFileUploadStrategy:: markAsDeleted path %s filename %s", $path, $filename));
68+
$from = empty($filename) ? $path : sprintf("%s/%s", $path, $filename);
69+
$to = null;
70+
if(empty($filename)){
71+
$parts = explode("/", $path);
72+
$parts[count($parts) - 1] = sprintf("DELETED_%s", $parts[count($parts) - 1] );
73+
$to = implode("/", $parts);
74+
}
75+
else{
76+
$to = sprintf("%s/DELETED_%s", $path, $filename);
77+
}
78+
Log::debug(sprintf("AbstractFileUploadStrategy:: markAsDeleted from %s to %s", $from, $to));
79+
80+
return Storage::disk($this->getDriver())->move
81+
(
82+
$from,
83+
$to
84+
);
7385
}
74-
else{
75-
$to = sprintf("%s/DELETED_%s", $path, $filename);
86+
catch(\Exception $ex){
87+
Log::error($ex);
7688
}
77-
Log::debug(sprintf("AbstractFileUploadStrategy:: markAsDeleted from %s to %s", $from, $to));
78-
79-
return Storage::disk($this->getDriver())->move
80-
(
81-
$from,
82-
$to
83-
);
8489
}
8590
}

0 commit comments

Comments
 (0)