ImportFiles takes a source directory or archive and copies to the uploaded files directory of a given app.
(uploadDir, importPath, extractPath string)
| 1270 | |
| 1271 | // ImportFiles takes a source directory or archive and copies to the uploaded files directory of a given app. |
| 1272 | func (app *DdevApp) ImportFiles(uploadDir, importPath, extractPath string) error { |
| 1273 | _ = app.DockerEnv() |
| 1274 | |
| 1275 | if err := app.ProcessHooks("pre-import-files"); err != nil { |
| 1276 | return err |
| 1277 | } |
| 1278 | |
| 1279 | if uploadDir == "" { |
| 1280 | uploadDir = app.GetUploadDir() |
| 1281 | if uploadDir == "" { |
| 1282 | return fmt.Errorf("upload_dirs is not set, cannot import files") |
| 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | if err := app.dispatchImportFilesAction(uploadDir, importPath, extractPath); err != nil { |
| 1287 | return err |
| 1288 | } |
| 1289 | // Some projects (backdrop or some drupal) need config that gets loaded from files dir. |
| 1290 | // These require mutagen sync before it will be available in container. |
| 1291 | // This is especially true with no-bind-mounts |
| 1292 | err := app.MutagenSyncFlush() |
| 1293 | if err != nil { |
| 1294 | return err |
| 1295 | } |
| 1296 | |
| 1297 | //nolint: revive |
| 1298 | if err = app.ProcessHooks("post-import-files"); err != nil { |
| 1299 | return err |
| 1300 | } |
| 1301 | |
| 1302 | return nil |
| 1303 | } |
| 1304 | |
| 1305 | // ComposeFiles returns a list of compose files for a project. |
| 1306 | // It has to put the .ddev/docker-compose.*.y*ml first |