Commit 31106cd7 authored by Lukas Böhm's avatar Lukas Böhm 🎱
Browse files

Update database.go

parent be9cf33e
......@@ -49,7 +49,13 @@ func (sh *Share) BeforeCreate(scope *gorm.DB) error {
} else {
return os.MkdirAll(filepath.Join(config.mediaDir, "data", sh.ID.String()), os.ModePerm)
}
}
func (sh *Share) BeforeDelete(scope *gorm.DB) error {
if sh.IsTemporary == false {
return os.RemoveAll(filepath.Join(config.mediaDir, "data", sh.ID.String()))
}
return nil
}
func (att *Attachment) BeforeCreate(scope *gorm.DB) error {
......@@ -63,6 +69,10 @@ func (att *Attachment) BeforeCreate(scope *gorm.DB) error {
return nil
}
func (att *Attachment) BeforeDelete(scope *gorm.DB) error {
return os.Remove(filepath.Join(config.mediaDir, "data", att.ShareID.String(), att.ID.String()))
}
func GetDatabase()(*gorm.DB, error) {
dsn := os.Getenv("DATABASE_URI")
split := strings.SplitN(dsn, ":", 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment