client도 storageroot지원

This commit is contained in:
2023-06-14 14:16:47 +09:00
parent 46aedbe767
commit 279c9f47f0
7 changed files with 60 additions and 36 deletions

View File

@ -56,9 +56,6 @@ func download(dir string, urlpath string, accessToken string) (string, error) {
return filepath.ToSlash(out.Name()), nil
}
func UnzipTest(fname string) error {
return unzip(fname)
}
func unzip(fname string) error {
archive, err := zip.OpenReader(fname)
if err != nil {
@ -161,8 +158,9 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
// houston관리용임을 표시하기 위해 더미파일 생성
defer func() {
var flagf *os.File
if _, err := os.Stat(path.Join(name, "@houston")); os.IsNotExist(err) {
flagf, err = os.Create(path.Join(name, "@houston"))
markerPath := path.Join(hc.config.StorageRoot, name, "@houston")
if _, err := os.Stat(markerPath); os.IsNotExist(err) {
flagf, err = os.Create(markerPath)
if err != nil {
return
}
@ -171,7 +169,7 @@ func (hc *houstonClient) prepareDeploy(name string, version string) (destPath st
}
}()
verpath := path.Join(name, version)
verpath := path.Join(hc.config.StorageRoot, name, version)
if _, err := os.Stat(verpath); os.IsNotExist(err) {
// 없네? 만들면 된다.
err = os.MkdirAll(verpath, 0775)
@ -293,7 +291,7 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
err = untar(fname)
}
if err == nil {
if err == nil && len(req.Config) > 0 {
// config.json도 다운로드
_, err = download(root, hc.makeDownloadUrl(req.Config), req.AccessToken)
}
@ -302,7 +300,8 @@ func (hc *houstonClient) deploy(req *shared.DeployRequest) error {
}
func (hc *houstonClient) withdraw(req *shared.WithdrawRequest) error {
fd, _ := os.Stat(path.Join(req.Name, req.Version))
targetPath := path.Join(hc.config.StorageRoot, req.Name, req.Version)
fd, _ := os.Stat(targetPath)
if fd != nil {
if fd.IsDir() {
for _, running := range hc.childProcs {
@ -312,7 +311,7 @@ func (hc *houstonClient) withdraw(req *shared.WithdrawRequest) error {
}
}
return os.RemoveAll(path.Join(req.Name, req.Version))
return os.RemoveAll(targetPath)
}
}