Fix #1090
Cette révision appartient à :
Parent
9fdb749e61
révision
e2d9381dfa
1 fichiers modifiés avec 4 ajouts et 4 suppressions
|
@ -16,15 +16,15 @@ import (
|
|||
|
||||
// ExistOrDelete : Check if a torrent exist with the same hash and if it can be replaced, it is replaced
|
||||
func ExistOrDelete(hash string, user *models.User) error {
|
||||
torrentIndb := models.Torrent{}
|
||||
models.ORM.Unscoped().Model(&models.Torrent{}).Where("torrent_hash = ?", hash).First(&torrentIndb)
|
||||
torrentIndb := &models.Torrent{}
|
||||
models.ORM.Unscoped().Model(&models.Torrent{}).Where("torrent_hash = ?", hash).Preload("Uploader").First(torrentIndb)
|
||||
if torrentIndb.ID > 0 {
|
||||
if user.CurrentUserIdentical(torrentIndb.UploaderID) && torrentIndb.IsDeleted() && !torrentIndb.IsBlocked() { // if torrent is not locked and is deleted and the user is the actual owner
|
||||
torrent, _, err := torrentIndb.DefinitelyDelete()
|
||||
_, _, err := torrentIndb.DefinitelyDelete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
activities.Log(&models.User{}, torrent.Identifier(), "delete", "torrent_deleted_by", strconv.Itoa(int(torrent.ID)), torrent.Uploader.Username, user.Username)
|
||||
activities.Log(&models.User{}, torrentIndb.Identifier(), "delete", "torrent_deleted_by", strconv.Itoa(int(torrentIndb.ID)), torrentIndb.Uploader.Username, user.Username)
|
||||
} else {
|
||||
return errors.New("Torrent already in database")
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket