protected function cleanupLocalFiles(array $newFiles)
    {
        $localPath = rtrim($this->request->getLocalPath(), DIRECTORY_SEPARATOR);

        // get local files not in newly downloaded files
        $deleteFiles = array_diff($this->files->files($localPath), $newFiles);

        foreach ($deleteFiles as $file) {

            if ( ! $this->files->delete($file)) {
                throw new \RuntimeException("Failed to delete local file for cleanup: {$file}");
            }

            event( new SshLocalFileDeleted($file, $localPath) );
        }
    }
protected function cleanupLocalFiles(array $newFiles)
    {
        $localPath = rtrim($this->request->getLocalPath(), DIRECTORY_SEPARATOR);

        // get local files not in newly downloaded files
        $deleteFiles = array_diff($this->files->files($localPath), $newFiles);

        foreach ($deleteFiles as $file) {

            if ( ! $this->files->delete($file)) {
                throw new \RuntimeException("Failed to delete local file for cleanup: {$file}");
            }

            event( new SshLocalFileDeleted($file, $localPath) );
        }
    }
protected function cleanupLocalFiles ( array $ newFiles ) { $ localPath = rtrim ( $ this -> request -> getLocalPath ( ) , DIRECTORY_SEPARATOR ) ; // get local files not in newly downloaded files $ deleteFiles = array_diff ( $ this -> files -> files ( $ localPath ) , $ newFiles ) ; foreach ( $ deleteFiles as $ file ) { if ( ! $ this -> files -> delete ( $ file ) ) { throw new \ RuntimeException ( "Failed to delete local file for cleanup: {$file}" ) ; } event ( new SshLocalFileDeleted ( $ file , $ localPath ) ) ; } }
Removes locally files that are not newly downloaded

@param string[] $newFiles
Removes locally files that are not newly downloaded