Scanner

class OC\Files\Cache\Scanner
Class Scanner
Hooks available in scope \OC\Files\Cache\Scanner:
- scanFile(string $path, string $storageId)
- scanFolder(string $path, string $storageId)
- postScanFile(string $path, string $storageId)
- postScanFolder(string $path, string $storageId)
Source:lib/private/Files/Cache/Scanner.php#58
Parent:OC\Hooks\BasicEmitter
Implements:OCP\Files\Cache\IScanner

Properties

protected static property OC\Files\Cache\Scanner::$storage
Source:lib/private/Files/Cache/Scanner.php#62
Type:\OC\Files\Storage\Storage
protected static property OC\Files\Cache\Scanner::$storageId
Source:lib/private/Files/Cache/Scanner.php#67
Type:string
protected static property OC\Files\Cache\Scanner::$cache
Source:lib/private/Files/Cache/Scanner.php#72
Type:\OC\Files\Cache\Cache
protected static property OC\Files\Cache\Scanner::$cacheActive
Source:lib/private/Files/Cache/Scanner.php#77
Type:bool If true, perform cache operations, if false, do not affect cache
protected static property OC\Files\Cache\Scanner::$useTransactions
Source:lib/private/Files/Cache/Scanner.php#82
Type:bool whether to use transactions
protected static property OC\Files\Cache\Scanner::$lockingProvider
Source:lib/private/Files/Cache/Scanner.php#87
Type:\OCP\Lock\ILockingProvider

Methods

public OC\Files\Cache\Scanner::__construct($storage)
Source:lib/private/Files/Cache/Scanner.php#89
public OC\Files\Cache\Scanner::setUseTransactions($useTransactions)
Whether to wrap the scanning of a folder in a database transaction
On default transactions are used
Source:

lib/private/Files/Cache/Scanner.php#103

Parameters:
  • $useTransactions (bool)
protected OC\Files\Cache\Scanner::getData($path)
get all the metadata of a file or folder
*
Source:

lib/private/Files/Cache/Scanner.php#114

Parameters:
  • $path (string)
Returns:

array | null an array of metadata of the file

public OC\Files\Cache\Scanner::scanFile($file, $reuseExisting=0, $parentId=-1, $cacheData=null, $lock=true, $data=null)
scan a single file and store it in the cache
Source:

lib/private/Files/Cache/Scanner.php#134

Parameters:
  • $file (string)
  • $reuseExisting (int)
  • $parentId (int)
  • $cacheData (array | null | bool) existing data in the cache for the file to be scanned
  • $lock (bool) set to false to disable getting an additional read lock during scanning
  • $data (null) the metadata for the file, as returned by the storage
Returns:

array | null an array of metadata of the scanned file

Throws:

\OCP\Lock\LockedException

protected OC\Files\Cache\Scanner::removeFromCache($path)
Source:lib/private/Files/Cache/Scanner.php#270
protected OC\Files\Cache\Scanner::addToCache($path, $data, $fileId=-1)
Source:

lib/private/Files/Cache/Scanner.php#284

Parameters:
  • $path (string)
  • $data (array)
  • $fileId (int)
Returns:

int the id of the added file

protected OC\Files\Cache\Scanner::updateCache($path, $data, $fileId=-1)
Source:

lib/private/Files/Cache/Scanner.php#307

Parameters:
  • $path (string)
  • $data (array)
  • $fileId (int)
public OC\Files\Cache\Scanner::scan($path, $recursive=self::SCAN_RECURSIVE, $reuse=-1, $lock=true)
scan a folder and all it’s children
Source:

lib/private/Files/Cache/Scanner.php#328

Parameters:
  • $path (string)
  • $recursive (bool)
  • $reuse (int)
  • $lock (bool) set to false to disable getting an additional read lock during scanning
Returns:

array | null an array of the meta data of the scanned file or folder

protected OC\Files\Cache\Scanner::getExistingChildren($folderId)
Get the children currently in the cache
Source:

lib/private/Files/Cache/Scanner.php#361

Parameters:
  • $folderId (int)
Returns:

array[]

protected OC\Files\Cache\Scanner::scanChildren($path, $recursive=self::SCAN_RECURSIVE, $reuse=-1, $folderId=null, $lock=true)
scan all the files and folders in a folder
Source:

lib/private/Files/Cache/Scanner.php#380

Parameters:
  • $path (string)
  • $recursive (bool)
  • $reuse (int)
  • $folderId (int) id for the folder to be scanned
  • $lock (bool) set to false to disable getting an additional read lock during scanning
Returns:

int the size of the scanned folder or -1 if the size is unknown at this stage

public static OC\Files\Cache\Scanner::isPartialFile($file)
check if the file should be ignored when scanning
NOTE: files with a ‘.part’ extension are ignored as well!
prevents unfinished put requests to be scanned
Source:

lib/private/Files/Cache/Scanner.php#488

Parameters:
  • $file (string)
Returns:

bool

public OC\Files\Cache\Scanner::backgroundScan()
walk over any folders that are not fully scanned yet and scan them
Source:lib/private/Files/Cache/Scanner.php#502
public OC\Files\Cache\Scanner::setCacheActive($active)
Set whether the cache is affected by scan operations
Source:

lib/private/Files/Cache/Scanner.php#543

Parameters:
  • $active (bool) The active state of the cache