GithubHelp home page GithubHelp logo

cleanmedia's Issues

SplFileInfo::getSize(): stat failed for /some/path/some_image.jpg

Counting the file size $size += $file->getSize(); occurs after the file is deleted $this->driverFile->deleteFile($file);, which leads to an error: SplFileInfo::getSize(): stat failed for /some/path/some_image.jpg

vendor/cap/cleanmedia/Console/Command/CleanMedia.php:118-137

/** @var SplFileInfo $file */
foreach ($iterator as $file) {
    if ($isNoCache) {
        if (strpos($file, "/cache") !== false) {
            continue;
        }
    }
    $filename = $file->getFilename();
    if (!in_array($filename, $inDb)) {
        $fileRelativePath = str_replace($mediaPath, '', $file->getPathname());
        if (!$isDryRun) {
            $output->writeln('<comment>REMOVING: </comment>' . $fileRelativePath);
            $this->driverFile->deleteFile($file);
        } else {
            $output->writeln('<comment>DRY-RUN: </comment>' . $fileRelativePath);
        }
        $count++;
        $size += $file->getSize();
    }
}

Run it in cron or in background

Hi,

Is it possible to run the command in cron? I'm wondering how the prompts (Continue? [Yes/No] for example) will react if I'm running it in cron or background.

Any advice?

Thanks!

Error in script

Hi. When running your script I get:
In ErrorHandler.php line 61:
Warning: filesize(): stat failed for myfolder/public_html/pub/media//catalog/product/image/321437726/. in myfolderpublic_html/app/code/Cap/CleanMedia/Console/Command/CleanMedia.php on line 108
And script stops. Can you help please?
magento 2.3.1 version

As I checked further this /321437726/ is empty...

Submit it to Packagist

Hi,

I just submitted your module to Packagist so it's available via Composer, do you want to do it yourself so it's related to your account?

Thanks for your work :)

Add an option to limit the number of files

Hi,

It would be nice to have an option to limit the number of files the command browses. I just runned it on a Magento with 5M+ files and the NFS server is running down.

Maybe something like php bin/magento cap:clean:media --limit=XXX.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.