protected function migrateFiles(
        $totalFileCount = null,
        $bulkCount,
        $dryRun,
        OutputInterface $output
    ) {
        $progress = new ProgressBar($output, $totalFileCount);
        if ($totalFileCount) {
            $progress->setFormat("%message%\n %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%");
        } else {
            $progress->setFormat("%message%\n %current% [%bar%] %elapsed:6s% %memory:6s%");
        }

        $output->writeln('');
        $progress->setMessage('Starting migration...');
        $progress->start();

        $elapsedFileCount = 0;
        $timestamp = microtime(true);
        $updateFrequency = 1;

        foreach ($this->fileListers as $fileLister) {
            $pass = 0;
            do {
                $metadataList = $fileLister->loadMetadataList($bulkCount, $pass * $bulkCount);

                foreach ($metadataList as $metadata) {
                    if (!$dryRun) {
                        $this->fileMigrator->migrateFile($metadata);
                    }

                    $progress->setMessage('Updated file ' . $metadata->id);
                    $progress->advance();
                    ++$elapsedFileCount;

                    // Magic that ensures the progressbar is updated ca. once per second
                    if (($elapsedFileCount % $updateFrequency) === 0) {
                        $newTimestamp = microtime(true);
                        if ($newTimestamp - $timestamp > 0.5 && $updateFrequency > 1) {
                            $updateFrequency = (int)($updateFrequency / 2);
                            $progress->setRedrawFrequency($updateFrequency);
                        } elseif ($newTimestamp - $timestamp < 0.1 && $updateFrequency < 10000) {
                            $updateFrequency = $updateFrequency * 2;
                            $progress->setRedrawFrequency($updateFrequency);
                        }
                        $timestamp = $newTimestamp;
                    }
                }

                ++$pass;
            } while (count($metadataList) > 0);
        }

        $progress->setMessage('');
        $progress->finish();

        $output->writeln("\n\nFinished processing $elapsedFileCount files.");
        if ($totalFileCount && $totalFileCount > $elapsedFileCount) {
            $output->writeln([
                'Files that could not be migrated: ' . ($totalFileCount - $elapsedFileCount),
                '',
            ]);
        }
    }
protected function migrateFiles(
        $totalFileCount = null,
        $bulkCount,
        $dryRun,
        OutputInterface $output
    ) {
        $progress = new ProgressBar($output, $totalFileCount);
        if ($totalFileCount) {
            $progress->setFormat("%message%\n %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%");
        } else {
            $progress->setFormat("%message%\n %current% [%bar%] %elapsed:6s% %memory:6s%");
        }

        $output->writeln('');
        $progress->setMessage('Starting migration...');
        $progress->start();

        $elapsedFileCount = 0;
        $timestamp = microtime(true);
        $updateFrequency = 1;

        foreach ($this->fileListers as $fileLister) {
            $pass = 0;
            do {
                $metadataList = $fileLister->loadMetadataList($bulkCount, $pass * $bulkCount);

                foreach ($metadataList as $metadata) {
                    if (!$dryRun) {
                        $this->fileMigrator->migrateFile($metadata);
                    }

                    $progress->setMessage('Updated file ' . $metadata->id);
                    $progress->advance();
                    ++$elapsedFileCount;

                    // Magic that ensures the progressbar is updated ca. once per second
                    if (($elapsedFileCount % $updateFrequency) === 0) {
                        $newTimestamp = microtime(true);
                        if ($newTimestamp - $timestamp > 0.5 && $updateFrequency > 1) {
                            $updateFrequency = (int)($updateFrequency / 2);
                            $progress->setRedrawFrequency($updateFrequency);
                        } elseif ($newTimestamp - $timestamp < 0.1 && $updateFrequency < 10000) {
                            $updateFrequency = $updateFrequency * 2;
                            $progress->setRedrawFrequency($updateFrequency);
                        }
                        $timestamp = $newTimestamp;
                    }
                }

                ++$pass;
            } while (count($metadataList) > 0);
        }

        $progress->setMessage('');
        $progress->finish();

        $output->writeln("\n\nFinished processing $elapsedFileCount files.");
        if ($totalFileCount && $totalFileCount > $elapsedFileCount) {
            $output->writeln([
                'Files that could not be migrated: ' . ($totalFileCount - $elapsedFileCount),
                '',
            ]);
        }
    }
protected function migrateFiles ( $ totalFileCount = null , $ bulkCount , $ dryRun , OutputInterface $ output ) { $ progress = new ProgressBar ( $ output , $ totalFileCount ) ; if ( $ totalFileCount ) { $ progress -> setFormat ( "%message%\n %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%" ) ; } else { $ progress -> setFormat ( "%message%\n %current% [%bar%] %elapsed:6s% %memory:6s%" ) ; } $ output -> writeln ( '' ) ; $ progress -> setMessage ( 'Starting migration...' ) ; $ progress -> start ( ) ; $ elapsedFileCount = 0 ; $ timestamp = microtime ( true ) ; $ updateFrequency = 1 ; foreach ( $ this -> fileListers as $ fileLister ) { $ pass = 0 ; do { $ metadataList = $ fileLister -> loadMetadataList ( $ bulkCount , $ pass * $ bulkCount ) ; foreach ( $ metadataList as $ metadata ) { if ( ! $ dryRun ) { $ this -> fileMigrator -> migrateFile ( $ metadata ) ; } $ progress -> setMessage ( 'Updated file ' . $ metadata -> id ) ; $ progress -> advance ( ) ; ++ $ elapsedFileCount ; // Magic that ensures the progressbar is updated ca. once per second if ( ( $ elapsedFileCount % $ updateFrequency ) === 0 ) { $ newTimestamp = microtime ( true ) ; if ( $ newTimestamp - $ timestamp > 0.5 && $ updateFrequency > 1 ) { $ updateFrequency = ( int ) ( $ updateFrequency / 2 ) ; $ progress -> setRedrawFrequency ( $ updateFrequency ) ; } elseif ( $ newTimestamp - $ timestamp < 0.1 && $ updateFrequency < 10000 ) { $ updateFrequency = $ updateFrequency * 2 ; $ progress -> setRedrawFrequency ( $ updateFrequency ) ; } $ timestamp = $ newTimestamp ; } } ++ $ pass ; } while ( count ( $ metadataList ) > 0 ) ; } $ progress -> setMessage ( '' ) ; $ progress -> finish ( ) ; $ output -> writeln ( "\n\nFinished processing $elapsedFileCount files." ) ; if ( $ totalFileCount && $ totalFileCount > $ elapsedFileCount ) { $ output -> writeln ( [ 'Files that could not be migrated: ' . ( $ totalFileCount - $ elapsedFileCount ) , '' , ] ) ; } }
Migrate files.

@param int|null $totalFileCount Total count of files, null if unknown
@param int $bulkCount Number of files to process in each batch
@param bool $dryRun
@param OutputInterface $output
Migrate files .