mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
remove caching share as caching should be done at a higher level
This commit is contained in:
parent
9e2dab941c
commit
7adbe91c9a
2 changed files with 2 additions and 77 deletions
|
|
@ -1,61 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
* See the COPYING-README file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace SMB;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class CachingShare
|
|
||||||
*
|
|
||||||
* caches metadata from share
|
|
||||||
*
|
|
||||||
* @package SMB
|
|
||||||
*/
|
|
||||||
class CachingShare extends Share {
|
|
||||||
private $dirCache = array();
|
|
||||||
|
|
||||||
private function clear($path = null) {
|
|
||||||
if (is_null($path)) {
|
|
||||||
$this->dirCache = array();
|
|
||||||
} else {
|
|
||||||
unset($this->dirCache[$path]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dir($path) {
|
|
||||||
if (!isset($this->dirCache[$path])) {
|
|
||||||
$this->dirCache[$path] = parent::dir($path);
|
|
||||||
}
|
|
||||||
return $this->dirCache[$path];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mkdir($path) {
|
|
||||||
$this->clear(dirname($path));
|
|
||||||
return parent::mkdir($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rmdir($path) {
|
|
||||||
$this->clear(dirname($path));
|
|
||||||
return parent::rmdir($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function del($path) {
|
|
||||||
$this->clear(dirname($path));
|
|
||||||
return parent::del($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function put($source, $target) {
|
|
||||||
$this->clear(dirname($target));
|
|
||||||
return parent::put($source, $target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rename($from, $to) {
|
|
||||||
$this->clear(dirname($from));
|
|
||||||
$this->clear(dirname($to));
|
|
||||||
return parent::rename($from, $to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -12,9 +12,6 @@ class Server {
|
||||||
const CLIENT = 'smbclient';
|
const CLIENT = 'smbclient';
|
||||||
const LOCALE = 'en_US.UTF-8';
|
const LOCALE = 'en_US.UTF-8';
|
||||||
|
|
||||||
const CACHING_ENABLED = true;
|
|
||||||
const CACHING_DISABLED = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $host
|
* @var string $host
|
||||||
*/
|
*/
|
||||||
|
|
@ -30,22 +27,15 @@ class Server {
|
||||||
*/
|
*/
|
||||||
private $password;
|
private $password;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool $caching
|
|
||||||
*/
|
|
||||||
private $caching;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $host
|
* @param string $host
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param bool $caching
|
|
||||||
*/
|
*/
|
||||||
public function __construct($host, $user, $password, $caching = self::CACHING_DISABLED) {
|
public function __construct($host, $user, $password) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
$this->caching = $caching;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,12 +121,8 @@ class Server {
|
||||||
* @return Share
|
* @return Share
|
||||||
*/
|
*/
|
||||||
public function getShare($name) {
|
public function getShare($name) {
|
||||||
if ($this->caching === self::CACHING_ENABLED) {
|
|
||||||
return new CachingShare($this, $name);
|
|
||||||
} else {
|
|
||||||
return new Share($this, $name);
|
return new Share($this, $name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue