fix: remove only the dump folder content instead of the folder.

This commit is contained in:
Fernandez Ludovic 2019-04-25 14:33:55 +02:00
parent 43ebd1bed3
commit 2fdc853d6d

View File

@ -22,11 +22,18 @@ type FileInfo struct {
// Dump Dumps data to certificates.
func Dump(data *StoredData, baseConfig *BaseConfig) error {
_, errExists := os.Stat(baseConfig.DumpPath)
if baseConfig.Clean {
if err := os.RemoveAll(baseConfig.DumpPath); err != nil {
if baseConfig.Clean && !os.IsNotExist(errExists) {
dir, err := ioutil.ReadDir(baseConfig.DumpPath)
if err != nil {
return err
}
for _, f := range dir {
if err := os.RemoveAll(filepath.Join(baseConfig.DumpPath, f.Name())); err != nil {
return err
}
}
}
if !baseConfig.DomainSubDir {