(appId string, fileName string)
| 287 | } |
| 288 | |
| 289 | func ReadAppFile(appId string, fileName string) (*FileData, error) { |
| 290 | if err := ValidateAppId(appId); err != nil { |
| 291 | return nil, fmt.Errorf("invalid appId: %w", err) |
| 292 | } |
| 293 | |
| 294 | appDir, err := GetAppDir(appId) |
| 295 | if err != nil { |
| 296 | return nil, err |
| 297 | } |
| 298 | |
| 299 | filePath, err := validateAndResolveFilePath(appDir, fileName) |
| 300 | if err != nil { |
| 301 | return nil, err |
| 302 | } |
| 303 | |
| 304 | fileInfo, err := os.Stat(filePath) |
| 305 | if err != nil { |
| 306 | return nil, fmt.Errorf("failed to stat file: %w", err) |
| 307 | } |
| 308 | |
| 309 | contents, err := os.ReadFile(filePath) |
| 310 | if err != nil { |
| 311 | return nil, fmt.Errorf("failed to read file: %w", err) |
| 312 | } |
| 313 | |
| 314 | return &FileData{ |
| 315 | Contents: contents, |
| 316 | ModTs: fileInfo.ModTime().UnixMilli(), |
| 317 | }, nil |
| 318 | } |
| 319 | |
| 320 | func DeleteAppFile(appId string, fileName string) error { |
| 321 | if err := ValidateAppId(appId); err != nil { |
no test coverage detected