Skip to content

Commit 0db1a00

Browse files
committed
feature(files): Add file type TYPE_SYMLINK to FileInfo
1 parent 03af157 commit 0db1a00

7 files changed

Lines changed: 17 additions & 7 deletions

File tree

apps/dav/lib/Connector/Sabre/Directory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function createSymlink($name, $target) {
229229
$storage->getUpdater()->update($internalPath);
230230
$newEtag = $storage->getETag($internalPath);
231231
$infoData = [
232-
'type' => FileInfo::TYPE_FILE,
232+
'type' => FileInfo::TYPE_SYMLINK,
233233
'etag' => $newEtag,
234234
];
235235
$path = \OC\Files\Filesystem::normalizePath($this->path . '/' . $name);

apps/files_reminders/lib/Notification/Notifier.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function prepare(INotification $notification, string $languageCode): INot
104104
$label = match ($node->getType()) {
105105
FileInfo::TYPE_FILE => $l->t('View file'),
106106
FileInfo::TYPE_FOLDER => $l->t('View folder'),
107+
FileInfo::TYPE_SYMLINK => $l->t('View symlink'),
107108
};
108109

109110
$this->addActionButton($notification, $label);

lib/private/Encryption/Util.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public function createHeader(array $headerData, IEncryptionModule $encryptionMod
154154

155155
/**
156156
* go recursively through a dir and collect all files and sub files.
157+
* the resulting list will not contain symlinks
157158
*
158159
* @param string $dir relative to the users files folder
159160
* @return array with list of files relative to the users files folder
@@ -167,9 +168,9 @@ public function getAllFiles($dir) {
167168
$content = $this->rootView->getDirectoryContent($dir);
168169

169170
foreach ($content as $c) {
170-
if ($c->getType() === 'dir') {
171+
if ($c->getType() === \OCP\Files\FileInfo::TYPE_FOLDER) {
171172
$dirList[] = $c->getPath();
172-
} else {
173+
} elseif($c->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
173174
$result[] = $c->getPath();
174175
}
175176
}

lib/private/Files/FileInfo.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public function getPermissions() {
248248
}
249249

250250
/**
251-
* @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
251+
* @return string \OCP\Files\FileInfo::TYPE_FILE|
252+
* \OCP\Files\FileInfo::TYPE_FOLDER
253+
* \OCP\Files\FileInfo::TYPE_SYMLINK
252254
*/
253255
public function getType() {
254256
if (!isset($this->data['type'])) {

lib/private/Files/Node/HookConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private function getNodeForPath(string $path): Node {
229229
return new NonExistingFile($this->root, $this->view, $fullPath, $info);
230230
}
231231
}
232-
if ($info->getType() === FileInfo::TYPE_FILE) {
232+
if ($info->getType() === FileInfo::TYPE_FILE || $info->getType() === FileInfo::TYPE_SYMLINK) {
233233
return new File($this->root, $this->view, $info->getPath(), $info);
234234
} else {
235235
return new Folder($this->root, $this->view, $info->getPath(), $info);

lib/public/Files/DavUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function getDavPermissions(FileInfo $info): string {
9494
if ($isWritable) {
9595
$p .= 'W';
9696
}
97-
} else {
97+
} elseif ($info->getType() === FileInfo::TYPE_FOLDER) {
9898
if ($permissions & Constants::PERMISSION_CREATE) {
9999
$p .= 'CK';
100100
}

lib/public/Files/FileInfo.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ interface FileInfo {
4545
* @since 7.0.0
4646
*/
4747
public const TYPE_FOLDER = 'dir';
48+
/**
49+
* @since TODO
50+
*/
51+
public const TYPE_SYMLINK = 'symlink';
4852

4953
/**
5054
* @const \OCP\Files\FileInfo::SPACE_NOT_COMPUTED Return value for a not computed space value
@@ -179,7 +183,9 @@ public function getPermissions();
179183
/**
180184
* Check whether this is a file or a folder
181185
*
182-
* @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
186+
* @return string \OCP\Files\FileInfo::TYPE_FILE|
187+
* \OCP\Files\FileInfo::TYPE_FOLDER|
188+
* \OCP\Files\FileInfo::TYPE_SYMLINK
183189
* @since 7.0.0
184190
*/
185191
public function getType();

0 commit comments

Comments
 (0)