Commit 36ca73a
committed
fix(storage): Unlink symlink instead of deleting target content and link
Nextcloud allow following symlink (https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#localstorage-allowsymlinks) but removal of symlink remove files in the target of the symlink and fail to remove the link returning an error.
Using the following structure:
```
.
├── afolder
│ └── test.txt
├── alink -> afolder
└── welcome.txt
```
created with:
```bash
mkdir afolder
touch afolder/test.txt
ln -s afolder alink
```
After deletion of `alink` symbolic link, the content of `afolder` is removed, the link also and an error is reported.
```json
{
"method":"DELETE",
"url":"/remote.php/dav/files/admin/alink",
"message":"rmdir(/data/dev/nextcloud/data/admin/files/alink): Not a directory at /data/dev/nextcloud/lib/private/Files/Storage/Local.php#128"
}
```
Results is:
```
.
├── afolder
└── welcome.txt
```
If the resource to be deleted is a link, unlink it (and preserve link target content).
```
.
├── afolder
│ └── test.txt
└── welcome.txt
```
Signed-off-by: Francois Prunayre <fx.prunayre@gmail.com>1 parent c4f071a commit 36ca73a
1 file changed
Lines changed: 29 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
106 | 103 | | |
107 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
108 | 107 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
112 | 123 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 124 | | |
119 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
120 | 128 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | 129 | | |
125 | 130 | | |
126 | 131 | | |
| |||
0 commit comments