()
| 155 | } |
| 156 | |
| 157 | func (f *FolderConfiguration) CreateMarker() error { |
| 158 | if err := f.CheckPath(); !errors.Is(err, ErrMarkerMissing) { |
| 159 | return err |
| 160 | } |
| 161 | if f.MarkerName != DefaultMarkerName { |
| 162 | // Folder uses a non-default marker so we shouldn't mess with it. |
| 163 | // Pretend we created it and let the subsequent health checks sort |
| 164 | // out the actual situation. |
| 165 | return nil |
| 166 | } |
| 167 | |
| 168 | ffs := f.Filesystem() |
| 169 | |
| 170 | // Create the marker as a directory |
| 171 | err := ffs.Mkdir(DefaultMarkerName, 0o755) |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | |
| 176 | // Create a file inside it, reducing the risk of the marker directory |
| 177 | // being removed by automated cleanup tools. |
| 178 | markerFile := filepath.Join(DefaultMarkerName, f.markerFilename()) |
| 179 | if err := fs.WriteFile(ffs, markerFile, f.markerContents(), 0o644); err != nil { |
| 180 | return err |
| 181 | } |
| 182 | |
| 183 | // Sync & hide the containing directory |
| 184 | if dir, err := ffs.Open("."); err != nil { |
| 185 | l.Debugln("folder marker: open . failed:", err) |
| 186 | } else if err := dir.Sync(); err != nil { |
| 187 | l.Debugln("folder marker: fsync . failed:", err) |
| 188 | } |
| 189 | ffs.Hide(DefaultMarkerName) |
| 190 | |
| 191 | return nil |
| 192 | } |
| 193 | |
| 194 | func (f *FolderConfiguration) RemoveMarker() error { |
| 195 | ffs := f.Filesystem() |
no test coverage detected