mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
Work around issue where 'allinfo' keeps the file open
This commit is contained in:
parent
6629a780b0
commit
ededbfbaa3
5 changed files with 57 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ use Icewind\SMB\Exception\AccessDeniedException;
|
|||
use Icewind\SMB\Exception\AlreadyExistsException;
|
||||
use Icewind\SMB\Exception\ConnectionException;
|
||||
use Icewind\SMB\Exception\Exception;
|
||||
use Icewind\SMB\Exception\FileInUseException;
|
||||
use Icewind\SMB\Exception\InvalidTypeException;
|
||||
use Icewind\SMB\Exception\NotEmptyException;
|
||||
use Icewind\SMB\Exception\NotFoundException;
|
||||
|
|
@ -70,6 +71,14 @@ class Share implements IShare {
|
|||
}
|
||||
}
|
||||
|
||||
protected function reconnect() {
|
||||
$this->connection->reconnect();
|
||||
$this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
|
||||
if (!$this->connection->isValid()) {
|
||||
throw new ConnectionException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the share
|
||||
*
|
||||
|
|
@ -150,12 +159,13 @@ class Share implements IShare {
|
|||
* Delete a file on the share
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $secondTry
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Icewind\SMB\Exception\NotFoundException
|
||||
* @throws \Icewind\SMB\Exception\InvalidTypeException
|
||||
* @throws InvalidTypeException
|
||||
* @throws NotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function del($path) {
|
||||
public function del($path, $secondTry = false) {
|
||||
//del return a file not found error when trying to delete a folder
|
||||
//we catch it so we can check if $path doesn't exist or is of invalid type
|
||||
try {
|
||||
|
|
@ -170,6 +180,12 @@ class Share implements IShare {
|
|||
throw new InvalidTypeException($path);
|
||||
}
|
||||
throw $e;
|
||||
} catch (FileInUseException $e) {
|
||||
if ($secondTry) {
|
||||
throw $e;
|
||||
}
|
||||
$this->reconnect();
|
||||
return $this->del($path, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue