What to check if PharData::buildFromDirectory fails to write contents of a file to a tar?

StackOverflow https://stackoverflow.com/questions/22229379

  •  06-06-2023
  •  | 
  •  

質問

I have a background script which generates html files (ea 100-500KB in size) as a by-product and when it has accumulated 500 of them, it packs them up in a .tar.gz and archives them. It was running non-stop for several weeks and generated 131 .tar.gz files thus far until this morning when it threw the following exception:

Uncaught exception 'PharException' with message 'tar-based phar
"E:/xampp/.../archive/1394109645.tar" cannot be created, contents of file 
"58836.html" could not be written' in E:/xampp/.../background.php:68

The code responsible for archiving

$name = $path_archive . $set . '.tar';
$archive = new PharData($name);
$archive->buildFromDirectory($path_input); // <--- line 68
$archive->compress(Phar::GZ);
unset($archive);
unlink($name);            
array_map('unlink', glob($path_input . '*'));

What I've checked and made sure of so far

  • I couldn't find anything irregular in the html file itself,
  • nothing else was touching this file during the process,
  • scripts timeout and memory were unlimited
  • and enough spare memory and disk space

What could be causing the exception and/or is there a way to get a more detailed message back from PharData::buildFromDirectory?

Env: Virtual XP (in VirtualBox) running portable XAMPP (1.8.2, PHP 5.4.25) in a shared folder of a Win7 host

正しい解決策はありません

他のヒント

I solved similar problem after hours of bug-hunting today. It was caused by too little space on one partition of the disk. I had enough space in the partition where tar.gz archive was created but after removing some log files from another partition everything works again.

I think it's possible that object PharData stores some temporary data somewhere and that's why this is happening even if there is enough space on the disk where you create tar.gz archive.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top