Skip to content

Commit

Permalink
feat: use /dev/shm instead of /tmp if it is available
Browse files Browse the repository at this point in the history
  • Loading branch information
simpletoimplement committed Sep 8, 2023
1 parent 54bcb77 commit 0de1285
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/XLSXParser/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use ZipArchive;

use function file_exists;
use function is_dir;
use function rmdir;
use function sprintf;
use function sys_get_temp_dir;
Expand All @@ -25,7 +26,12 @@ final class Archive

public function __construct(private readonly string $archivePath)
{
$this->tmpPath = tempnam(directory: sys_get_temp_dir(), prefix: 'spaghetti_xlsx_parser_archive');
$tmpDir = sys_get_temp_dir();
if (is_dir(filename: '/dev/shm')) {
$tmpDir = '/dev/shm';
}

$this->tmpPath = tempnam(directory: $tmpDir, prefix: 'spaghetti_xlsx_parser_archive');
unlink(filename: $this->tmpPath);
}

Expand Down

0 comments on commit 0de1285

Please sign in to comment.