Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Solve the error when try to remove a file previously removed, the ide…
Browse files Browse the repository at this point in the history
…a is to remove first the imagekeys files and then, the remaining files of the temporary directory
  • Loading branch information
josepsanzcamp committed Mar 25, 2021
1 parent 11269e4 commit ad5d30b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7710,7 +7710,15 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
}
if ($destroyall AND !$preserve_objcopy) {
self::$cleaned_ids[$this->file_id] = true;
// remove all temporary files
// first: remove all imagekeys files
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0 && file_exists($file)) {
unlink($file);
}
}
}
// second: remove all remaining temporary files
if ($handle = @opendir(K_PATH_CACHE)) {
while (false !== ($file_name = readdir($handle))) {
if (strpos($file_name, '__tcpdf_'.$this->file_id.'_') === 0) {
Expand All @@ -7719,13 +7727,6 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
}
closedir($handle);
}
if (isset($this->imagekeys)) {
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0 && file_exists($file)) {
@unlink($file);
}
}
}
}
$preserve = array(
'file_id',
Expand Down

0 comments on commit ad5d30b

Please sign in to comment.