/** {@inheritdoc} */ public function touch($path, $mtime = null) { $this->init(); if (is_null($mtime)) { $mtime = time(); } $path = $this->cleanPath($path); // if file exists, update the mtime, else create a new empty file if ($this->file_exists($path)) { try { $this->statCache->remove($path); $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime)); } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 501) { return false; } $this->convertException($e); return false; } catch (\Exception $e) { $this->convertException($e); return false; } } else { $this->file_put_contents($path, ''); } return true; }
public function touch($path, $mtime = null) { $this->init(); if (is_null($mtime)) { $mtime = time(); } $path = $this->cleanPath($path); // if file exists, update the mtime, else create a new empty file if ($this->file_exists($path)) { try { $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime)); } catch (Exception\NotImplemented $e) { return false; } catch (\Sabre\DAV\Exception $e) { $this->convertSabreException($e); return false; } catch (\Exception $e) { // TODO: log for now, but in the future need to wrap/rethrow exception \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); return false; } } else { $this->file_put_contents($path, ''); } return true; }
public function touch($path, $mtime = null) { $this->init(); if (is_null($mtime)) { $mtime = time(); } $path = $this->cleanPath($path); // if file exists, update the mtime, else create a new empty file if ($this->file_exists($path)) { try { $this->client->proppatch($this->encodePath($path), array('{DAV:}lastmodified' => $mtime)); } catch (\Sabre\DAV\Exception\NotImplemented $e) { return false; } } else { $this->file_put_contents($path, ''); } return true; }
/** {@inheritdoc} */ public function touch($path, $mtime = null) { $this->init(); if (is_null($mtime)) { $mtime = time(); } $path = $this->cleanPath($path); // if file exists, update the mtime, else create a new empty file if ($this->file_exists($path)) { try { $this->statCache->remove($path); $this->client->proppatch($this->encodePath($path), ['{DAV:}lastmodified' => $mtime]); // non-owncloud clients might not have accepted the property, need to recheck it $response = $this->client->propfind($this->encodePath($path), ['{DAV:}getlastmodified'], 0); if (isset($response['{DAV:}getlastmodified'])) { $remoteMtime = strtotime($response['{DAV:}getlastmodified']); if ($remoteMtime !== $mtime) { // server has not accepted the mtime return false; } } } catch (ClientHttpException $e) { if ($e->getHttpStatus() === 501) { return false; } $this->convertException($e, $path); return false; } catch (\Exception $e) { $this->convertException($e, $path); return false; } } else { $this->file_put_contents($path, ''); } return true; }
public function changeFavStateOfAnElement($user, $path, $favOrUnfav, $folderDepth, $properties = null) { $fullUrl = substr($this->baseUrl, 0, -4); $settings = array('baseUri' => $fullUrl, 'userName' => $user); if ($user === 'admin') { $settings['password'] = $this->adminUser[1]; } else { $settings['password'] = $this->regularUser; } $client = new SClient($settings); if (!$properties) { $properties = ['{http://owncloud.org/ns}favorite' => $favOrUnfav]; } $response = $client->proppatch($this->davPath . '/' . ltrim($path, '/'), $properties, $folderDepth); return $response; }