1

我正在尝试使用 Phar Classe 提取 tar 文件,但返回以下错误:

UnexpectedValueException Object ( [message:protected] => phar error: "/home/filelocation/file.tar" is a corrupted tar file (truncated) [string:Exception:private] => [code:protected] => 0 [file:protected] => /home/inplan/public_html/uncompress_files.php [line:protected] => 89 [trace:Exception:private] => Array ( [0] => Array ( [file] => /home/inplan/public_html/uncompress_files.php [line] => 89 [function] => __construct [class] => PharData [type] => -> [args] => Array ( [0] => uploads/maps/true_color_4.tar ) ) ) [previous:Exception:private] => )

PHP:

try {
    $phar = new PharData('uploads/maps/true_color_'.$id_technical_report.'.tar');
    $phar2 = $phar->convertToExecutable (Phar::TAR,Phar::NONE);
    $phar2->extractTo('uploads/maps/');
} catch (Exception $e) {
    print_r($e);
}

当我下载这个文件时,我可以使用 Winrar 正常打开和解压。

该文件由 Sentinel Hub ( https://services.sentinel-hub.com/api/v1/process )的 API 生成

任何想法为什么会发生这种情况?

谢谢

4

1 回答 1

0

我从一个构建 tar 文件的自制 tar 程序中得到了同样的信息。我无法用 PHAR 类解压它。问题是 CRC 字段,写在 tar 文件的最后一行,它被最初生成该 tar 文件的程序计算错误。

于 2021-08-07T22:35:24.207 回答