gpt4 book ai didi

homestead - fwrite() : write of XX bytes failed with errno=5 Input/output error

转载 作者:行者123 更新时间:2023-12-04 02:28:44 25 4
gpt4 key购买 nike

我之前有 2 个类似的问题,但是经过更多的调试后,我得出的结论是问题(可能)不在我自己的代码中。
在我的代码中,我试图解压缩一个 gzipped 文件,为此我编写了一个小方法;

<?php

namespace App\Helpers;

class Gzip
{

public static function unzip($filePath)
{
$outFilePath = str_replace('.gz', '', $filePath);

// Open our files (in binary mode)
$file = gzopen($filePath, 'rb');
$outFile = fopen($outFilePath, 'wb');

// Keep repeating until the end of the input file
while (!gzeof($file)) {
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
fwrite($outFile, gzread($file, 4096));
}

// Files are done, close files
fclose($outFile);
gzclose($file);
}
}
这应该会导致解压文件;
Gzip::unzip('path/to/file.csv.gz');
这就是它变得棘手的地方,有时它会解压缩文件,有时它会抛出这个异常; (请记住,这与 StreamHandler 本身无关,这是一个纯输入/输出错误问题)
exception fwrite
我可以根据需要多次刷新页面,但如果我尝试使用 gunzip,则不会有任何改变。命令行上的命令它将失败并排序相同的错误;
gunzip error
  • 我解压缩哪个文件并不重要,它随机发生在一个随机文件上。

  • 现在我是否运行 gunzip 也无关紧要命令多次,但就像我说的,这些异常/错误是随机发生的,所以它们也会随机“修复”它们。
    该应用程序是用 Laravel 8.0 编写的,PHP7.4 在 Homestead 环境(Ubuntu 18.04.5 LTS)上运行,我的基本笔记本电脑在 Windows 10 上运行。
    对我来说,这个异常/错误是随机发生的,而且也是随机的“修复”本身,这是非常奇怪的,所以我的问题是:这是怎么发生的,为什么会发生这种情况,最终我该如何修复它。

    最佳答案

    errno=5 Input/output error是读/写Linux文件系统失败。
    真正的服务器,需要用fsck等检查磁盘...
    Homestead 在 Windows 上运行,我认为我们应该寻找 windows 10 homestead errno -5问题。
    winnfsd - https://github.com/winnfsd/vagrant-winnfsd/issues/96#issuecomment-336105685

    关于homestead - fwrite() : write of XX bytes failed with errno=5 Input/output error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65569643/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com