diff --git a/store/files.go b/store/files.go index e7ea82e4d6233f631758483effeabb3c3eff48a0..55c41f4ec8c50ddc1f2e44cc3d7e7ab5c744470b 100644 --- a/store/files.go +++ b/store/files.go @@ -211,23 +211,12 @@ func (st *Store) UpdateFileSourceHash(showID uint64, id uint64, hash string) (fi return st.updateHash(showID, id, hash) } -func (st *Store) getFileUsage(id uint64, playlists *[]Playlist) (err error) { - sub := st.db.Model(PlaylistEntry{}).Select("playlist_id").Where("file_id = ?", id).Group("playlist_id") - err = st.db.Where("id in (?)", sub).Find(playlists).Error - return -} - func (st *Store) DeleteFile(showID uint64, id uint64) (err error) { // make sure the file actually belongs to <show> since permissions are enforced // based on show membership result := st.db.Where("show_id = ?", showID).Where("id = ?", id).Delete(File{}) if err = result.Error; err != nil { - // we assume this is due to a FK constraint -> file in use by playlist_entry - usageErr := &ErrFileInUse{} - if err = st.getFileUsage(id, &usageErr.Playlists); err != nil { - return - } - return usageErr + return } if result.RowsAffected == 0 { return ErrNotFound