Class Sabre_DAV_TemporaryFileFilterPlugin

Description

Temporary File Filter Plugin

The purpose of this filter is to intercept some of the garbage files operation systems and applications tend to generate when mounting a WebDAV share as a disk.

It will intercept these files and place them in a separate directory. these files are not deleted automatically, so it is adviceable to delete these after they are not accessed for 24 hours.

Currently it supports: * OS/X style resource forks and .DS_Store * desktop.ini and Thumbs.db (windows) * .*.swp (vim temporary files) * .dat.* (smultron temporary files)

Additional patterns can be added, by adding on to the temporaryFilePatterns property.

  • author: Evert Pot (http://www.rooftopsolutions.nl/)
  • copyright: Copyright (C) 2007-2010 Rooftop Solutions. All rights reserved.
  • license: Modified BSD License

Located in /sources_custom/Sabre/DAV/TemporaryFileFilterPlugin.php (line 29)

Sabre_DAV_ServerPlugin
   |
   --Sabre_DAV_TemporaryFileFilterPlugin
Variable Summary
Method Summary
void __construct ([string $dataDir = null])
bool beforeCreateFile (string $uri, resource $data)
bool beforeMethod (string $method,  $uri)
bool httpDelete (string $tempLocation)
bool httpGet (string $tempLocation)
void httpPropfind (string $tempLocation,  $uri)
bool httpPut (string $tempLocation)
void initialize (Sabre_DAV_Server $server)
boolean|string isTempFile (string $path)
Variables
array $temporaryFilePatterns = array(
'/^\._(.*)$/', // OS/X resource forks
'/^.DS_Store$/', // OS/X custom folder settings
'/^desktop.ini$/', // Windows custom folder settings
'/^Thumbs.db$/', // Windows thumbnail cache
'/^.(.*).swp$/', // ViM temporary files
'/^\.dat(.*)$/', // Smultron seems to create these
'/^~lock.(.*)#$/', // Windows 7 lockfiles
)
(line 37)

This is the list of patterns we intercept.

If new patterns are added, they must be valid patterns for preg_match.

  • access: public
Methods
Constructor __construct (line 72)

Creates the plugin.

Make sure you specify a directory for your files. If you don't, we will use PHP's directory for session-storage instead, and you might not want that.

  • access: public
void __construct ([string $dataDir = null])
  • string $dataDir
beforeCreateFile (line 135)

This method is invoked if some subsystem creates a new file.

This is used to deal with HTTP LOCK requests which create a new file.

  • access: public
bool beforeCreateFile (string $uri, resource $data)
  • string $uri
  • resource $data
beforeMethod (line 106)

This method is called before any HTTP method handler

This method intercepts any GET, DELETE, PUT and PROPFIND calls to filenames that are known to match the 'temporary file' regex.

  • access: public
bool beforeMethod (string $method,  $uri)
  • string $method
  • $uri
httpDelete (line 228)

This method handles the DELETE method.

If the file didn't exist, it will return false, which will make the standard HTTP DELETE handler kick in.

  • access: public
bool httpDelete (string $tempLocation)
  • string $tempLocation
httpGet (line 182)

This method handles the GET method for temporary files.

If the file doesn't exist, it will return false which will kick in the regular system for the GET method.

  • access: public
bool httpGet (string $tempLocation)
  • string $tempLocation
httpPropfind (line 250)

This method handles the PROPFIND method.

It's a very lazy method, it won't bother checking the request body for which properties were requested, and just sends back a default set of properties.

  • access: public
void httpPropfind (string $tempLocation,  $uri)
  • string $tempLocation
  • $uri
httpPut (line 202)

This method handles the PUT method.

  • access: public
bool httpPut (string $tempLocation)
  • string $tempLocation
initialize (line 89)

Initialize the plugin

This is called automatically be the Server class after this plugin is added with Sabre_DAV_Server::addPlugin()

  • access: public
void initialize (Sabre_DAV_Server $server)

Redefinition of:
Sabre_DAV_ServerPlugin::initialize()
This initializes the plugin.
isTempFile (line 156)

This method will check if the url matches the temporary file pattern if it does, it will return an path based on $this->dataDir for the temporary file storage.

  • access: protected
boolean|string isTempFile (string $path)
  • string $path

Inherited Methods

Inherited From Sabre_DAV_ServerPlugin

Sabre_DAV_ServerPlugin::getFeatures()
Sabre_DAV_ServerPlugin::getHTTPMethods()
Sabre_DAV_ServerPlugin::initialize()

Documentation generated on Sun, 02 Jan 2011 23:26:26 +0000 by phpDocumentor 1.4.3