ProcessPath takes in a director of app files or a zip file which contains the app files. If given a zip file, it will extract the zip to a temporary location, call the provided callback with that location, and then clean up the location after the callback has been executed. This was done so that th
(dirOrZipFile string, f func(string) error)
| 55 | // responsible for cleaning up the temporary directory ProcessPath creates when |
| 56 | // given a zip. |
| 57 | func (actor PushActorImpl) ProcessPath(dirOrZipFile string, f func(string) error) error { |
| 58 | if !actor.zipper.IsZipFile(dirOrZipFile) { |
| 59 | if filepath.IsAbs(dirOrZipFile) { |
| 60 | appDir, err := filepath.EvalSymlinks(dirOrZipFile) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | err = f(appDir) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | } else { |
| 69 | absPath, err := filepath.Abs(dirOrZipFile) |
| 70 | if err != nil { |
| 71 | return err |
| 72 | } |
| 73 | appDir, err := filepath.EvalSymlinks(absPath) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | err = f(appDir) |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | tempDir, err := ioutil.TempDir("", "unzipped-app") |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | |
| 92 | err = actor.zipper.Unzip(dirOrZipFile, tempDir) |
| 93 | if err != nil { |
| 94 | return err |
| 95 | } |
| 96 | |
| 97 | err = f(tempDir) |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | err = os.RemoveAll(tempDir) |
| 103 | if err != nil { |
| 104 | return err |
| 105 | } |
| 106 | |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | func (actor PushActorImpl) GatherFiles(localFiles []models.AppFileFields, appDir string, uploadDir string, useCache bool) ([]resources.AppFileResource, bool, error) { |
| 111 | appFileResource := []resources.AppFileResource{} |