use OCA\DAV\Connector\Sabre\MtimeSanitizer;
class BulkUploadPlugin extends ServerPlugin {
+ private Folder $userFolder;
+ private LoggerInterface $logger;
- /** @var Folder */
- private $userFolder;
-
- /** @var LoggerInterface */
- private $logger;
-
- public function __construct(Folder $userFolder, LoggerInterface $logger) {
+ public function __construct(
+ Folder $userFolder,
+ LoggerInterface $logger
+ ) {
$this->userFolder = $userFolder;
$this->logger = $logger;
}
$writtenFiles[$headers['x-file-path']] = [
"error" => false,
"etag" => $node->getETag(),
- "fileid" => $node->getFileId(),
- "permissions" => $node->getDavPermissions(),
+ "fileid" => \OCP\Util::getDavFileId($node->getId()),
+ "permissions" => \OCP\Util::getDavPermissions($node),
];
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['path' => $headers['x-file-path']]);
* @return string|null
*/
public function getFileId() {
- if ($this->info->getId()) {
- $instanceId = \OC_Util::getInstanceId();
- $id = sprintf('%08d', $this->info->getId());
- return $id . $instanceId;
+ if ($id = $this->info->getId()) {
+ return \OCP\Util::getDavFileId($id);
}
return null;
* @return string
*/
public function getDavPermissions() {
- $p = '';
- if ($this->info->isShared()) {
- $p .= 'S';
- }
- if ($this->info->isShareable()) {
- $p .= 'R';
- }
- if ($this->info->isMounted()) {
- $p .= 'M';
- }
- if ($this->info->isReadable()) {
- $p .= 'G';
- }
- if ($this->info->isDeletable()) {
- $p .= 'D';
- }
- if ($this->info->isUpdateable()) {
- $p .= 'NV'; // Renameable, Moveable
- }
- if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
- if ($this->info->isUpdateable()) {
- $p .= 'W';
- }
- } else {
- if ($this->info->isCreatable()) {
- $p .= 'CK';
- }
- }
- return $p;
+ return \OCP\Util::getDavPermissions($this->info);
}
public function getOwner() {
$view
));
$this->server->addPlugin(
- new BulkUploadPlugin($userFolder, $logger)
+ new BulkUploadPlugin(
+ $userFolder,
+ $logger
+ )
);
}
$this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin(
}
return true;
}
+
+ /**
+ * @param int $id Id of the file returned by FileInfo::getId
+ */
+ public static function getDavFileId(int $id): string {
+ $instanceId = \OC_Util::getInstanceId();
+ $id = sprintf('%08d', $id);
+ return $id . $instanceId;
+ }
+
+ public static function getDavPermissions(\OCP\Files\FileInfo $info): string {
+ $p = '';
+ if ($info->isShared()) {
+ $p .= 'S';
+ }
+ if ($info->isShareable()) {
+ $p .= 'R';
+ }
+ if ($info->isMounted()) {
+ $p .= 'M';
+ }
+ if ($info->isReadable()) {
+ $p .= 'G';
+ }
+ if ($info->isDeletable()) {
+ $p .= 'D';
+ }
+ if ($info->isUpdateable()) {
+ $p .= 'NV'; // Renameable, Moveable
+ }
+ if ($info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
+ if ($info->isUpdateable()) {
+ $p .= 'W';
+ }
+ } else {
+ if ($info->isCreatable()) {
+ $p .= 'CK';
+ }
+ }
+ return $p;
+ }
}