Fix webdav destination header when overwriting folders
The trailing slash is needed when talking to Apache's mod_dav server
This commit is contained in:
parent
a76498f245
commit
6f346b4b1f
|
@ -506,13 +506,18 @@ class DAV extends Common {
|
||||||
$path1 = $this->cleanPath($path1);
|
$path1 = $this->cleanPath($path1);
|
||||||
$path2 = $this->cleanPath($path2);
|
$path2 = $this->cleanPath($path2);
|
||||||
try {
|
try {
|
||||||
|
// overwrite directory ?
|
||||||
|
if ($this->is_dir($path2)) {
|
||||||
|
// needs trailing slash in destination
|
||||||
|
$path2 = rtrim($path2, '/') . '/';
|
||||||
|
}
|
||||||
$this->client->request(
|
$this->client->request(
|
||||||
'MOVE',
|
'MOVE',
|
||||||
$this->encodePath($path1),
|
$this->encodePath($path1),
|
||||||
null,
|
null,
|
||||||
array(
|
[
|
||||||
'Destination' => $this->createBaseUri() . $this->encodePath($path2)
|
'Destination' => $this->createBaseUri() . $this->encodePath($path2),
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$this->statCache->clear($path1 . '/');
|
$this->statCache->clear($path1 . '/');
|
||||||
$this->statCache->clear($path2 . '/');
|
$this->statCache->clear($path2 . '/');
|
||||||
|
@ -530,10 +535,22 @@ class DAV extends Common {
|
||||||
/** {@inheritdoc} */
|
/** {@inheritdoc} */
|
||||||
public function copy($path1, $path2) {
|
public function copy($path1, $path2) {
|
||||||
$this->init();
|
$this->init();
|
||||||
$path1 = $this->encodePath($this->cleanPath($path1));
|
$path1 = $this->cleanPath($path1);
|
||||||
$path2 = $this->createBaseUri() . $this->encodePath($this->cleanPath($path2));
|
$path2 = $this->cleanPath($path2);
|
||||||
try {
|
try {
|
||||||
$this->client->request('COPY', $path1, null, array('Destination' => $path2));
|
// overwrite directory ?
|
||||||
|
if ($this->is_dir($path2)) {
|
||||||
|
// needs trailing slash in destination
|
||||||
|
$path2 = rtrim($path2, '/') . '/';
|
||||||
|
}
|
||||||
|
$this->client->request(
|
||||||
|
'COPY',
|
||||||
|
$this->encodePath($path1),
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
'Destination' => $this->createBaseUri() . $this->encodePath($path2),
|
||||||
|
]
|
||||||
|
);
|
||||||
$this->statCache->clear($path2 . '/');
|
$this->statCache->clear($path2 . '/');
|
||||||
$this->statCache->set($path2, true);
|
$this->statCache->set($path2, true);
|
||||||
$this->removeCachedFile($path2);
|
$this->removeCachedFile($path2);
|
||||||
|
|
Loading…
Reference in New Issue