fix: remove only the dump folder content instead of the folder.
This commit is contained in:
parent
2fdc853d6d
commit
ac45aaac27
@ -22,18 +22,11 @@ type FileInfo struct {
|
|||||||
|
|
||||||
// Dump Dumps data to certificates.
|
// Dump Dumps data to certificates.
|
||||||
func Dump(data *StoredData, baseConfig *BaseConfig) error {
|
func Dump(data *StoredData, baseConfig *BaseConfig) error {
|
||||||
_, errExists := os.Stat(baseConfig.DumpPath)
|
if baseConfig.Clean {
|
||||||
|
err := clean(baseConfig.DumpPath)
|
||||||
if baseConfig.Clean && !os.IsNotExist(errExists) {
|
|
||||||
dir, err := ioutil.ReadDir(baseConfig.DumpPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, f := range dir {
|
|
||||||
if err := os.RemoveAll(filepath.Join(baseConfig.DumpPath, f.Name())); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !baseConfig.DomainSubDir {
|
if !baseConfig.DomainSubDir {
|
||||||
@ -110,3 +103,27 @@ func extractPEMPrivateKey(account *Account) []byte {
|
|||||||
|
|
||||||
return pem.EncodeToMemory(block)
|
return pem.EncodeToMemory(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clean(dumpPath string) error {
|
||||||
|
_, errExists := os.Stat(dumpPath)
|
||||||
|
if os.IsNotExist(errExists) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if errExists != nil {
|
||||||
|
return errExists
|
||||||
|
}
|
||||||
|
|
||||||
|
dir, err := ioutil.ReadDir(dumpPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range dir {
|
||||||
|
if err := os.RemoveAll(filepath.Join(dumpPath, f.Name())); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user