MCPcopy Index your code
hub / github.com/ddev/ddev / ImportFiles

Method ImportFiles

pkg/ddevapp/ddevapp.go:1272–1303  ·  view source on GitHub ↗

ImportFiles takes a source directory or archive and copies to the uploaded files directory of a given app.

(uploadDir, importPath, extractPath string)

Source from the content-addressed store, hash-verified

1270
1271// ImportFiles takes a source directory or archive and copies to the uploaded files directory of a given app.
1272func (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

Callers 8

TestDdevFullSiteSetupFunction · 0.95
TestDdevImportFilesDirFunction · 0.95
TestDdevImportFilesFunction · 0.95
TestConfigValidateFunction · 0.80
doFilesImportMethod · 0.80
importFilesRunFunction · 0.80

Calls 6

DockerEnvMethod · 0.95
ProcessHooksMethod · 0.95
GetUploadDirMethod · 0.95
MutagenSyncFlushMethod · 0.95
ErrorfMethod · 0.80

Tested by 6

TestDdevFullSiteSetupFunction · 0.76
TestDdevImportFilesDirFunction · 0.76
TestDdevImportFilesFunction · 0.76
TestConfigValidateFunction · 0.64