Commit 63ebd2b
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 13ae34a commit 63ebd2b
1 file changed
Lines changed: 29 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
114 | 111 | | |
115 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
116 | 115 | | |
117 | | - | |
118 | | - | |
119 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
120 | 131 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 132 | | |
127 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
128 | 136 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
0 commit comments