| 226 | } |
| 227 | |
| 228 | func (s *FileStore) WriteFile(ctx context.Context, zoneId string, name string, data []byte) error { |
| 229 | return withLock(s, zoneId, name, func(entry *CacheEntry) error { |
| 230 | err := entry.loadFileIntoCache(ctx) |
| 231 | if err != nil { |
| 232 | return err |
| 233 | } |
| 234 | entry.writeAt(0, data, true) |
| 235 | // since WriteFile can *truncate* the file, we need to flush the file to the DB immediately |
| 236 | return entry.flushToDB(ctx, true) |
| 237 | }) |
| 238 | } |
| 239 | |
| 240 | func (s *FileStore) WriteAt(ctx context.Context, zoneId string, name string, offset int64, data []byte) error { |
| 241 | if offset < 0 { |