mirror of
https://github.com/tgdrive/teldrive.git
synced 2024-12-28 19:04:07 +08:00
refactor: Purge share cache entry post delete
This commit is contained in:
parent
99bf608792
commit
286bacaefe
3 changed files with 10 additions and 3 deletions
|
@ -65,7 +65,7 @@ func NewRun() *cobra.Command {
|
|||
duration.DurationVar(runCmd.Flags(), &config.CronJobs.FolderSizeInterval, "cronjobs-folder-size-interval", 2*time.Hour, "Folder size update interval")
|
||||
|
||||
runCmd.Flags().IntVar(&config.Cache.MaxSize, "cache-max-size", 10*1024*1024, "Max Cache max size (memory)")
|
||||
runCmd.Flags().StringVar(&config.Cache.RedisAddr, "cache-redis-addr", "localhost:6379", "Redis address")
|
||||
runCmd.Flags().StringVar(&config.Cache.RedisAddr, "cache-redis-addr", "", "Redis address")
|
||||
runCmd.Flags().StringVar(&config.Cache.RedisPass, "cache-redis-pass", "", "Redis password")
|
||||
|
||||
runCmd.Flags().IntVarP(&config.Log.Level, "log-level", "", -1, "Logging level")
|
||||
|
|
|
@ -234,7 +234,7 @@ func GetLocation(ctx context.Context, client *tg.Client, channelId int64, partId
|
|||
}
|
||||
|
||||
func CalculateChunkSize(start, end int64) int64 {
|
||||
chunkSize := int64(512 * 1024)
|
||||
chunkSize := int64(1024 * 1024)
|
||||
|
||||
for chunkSize > 1024 && chunkSize > (end-start) {
|
||||
chunkSize /= 2
|
||||
|
|
|
@ -473,10 +473,17 @@ func (fs *FileService) GetShareByFileId(fileId string, userId int64) (*schemas.F
|
|||
|
||||
func (fs *FileService) DeleteShare(fileId string, userId int64) *types.AppError {
|
||||
|
||||
if err := fs.db.Where("file_id = ?", fileId).Where("user_id = ?", userId).Delete(&models.FileShare{}).Error; err != nil {
|
||||
var deletedShare models.FileShare
|
||||
|
||||
if err := fs.db.Clauses(clause.Returning{}).Where("file_id = ?", fileId).Where("user_id = ?", userId).
|
||||
Delete(&deletedShare).Error; err != nil {
|
||||
return &types.AppError{Error: err}
|
||||
}
|
||||
|
||||
if deletedShare.ID != "" {
|
||||
fs.cache.Delete(fmt.Sprintf("shares:%s", deletedShare.ID))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue