Notify user if files too large

This commit is contained in:
Keroosha 2023-04-13 23:59:45 +03:00
parent a353ee0f3b
commit 0d97e405b4
2 changed files with 32 additions and 15 deletions

View File

@ -13,9 +13,13 @@ After=network.target
Type=simple Type=simple
# Command with arguments to invoke when the unit is activated. # Command with arguments to invoke when the unit is activated.
ExecStart=/opt/apps/Keroosha.SilncerBot/app/Keroosha.SilencerBot ExecStart=/opt/apps/Keroosha.SilncerBot/app/Keroosha.SilencerBot
WorkingDirectory=/opt/apps/Keroosha.SilncerBot/app
# Configures under what conditions the unit will be restarted. # Configures under what conditions the unit will be restarted.
Restart=on-failure User=apps
Restart=always
CPUQuota=15% CPUQuota=15%
KillSignal=SIGINT
Environment=SILENCER_BOT_CONFIG_PATH=/opt/apps/Keroosha.SilncerBot/config/config.json
[Install] [Install]
# A list of units who when activated will try and activate this unit # A list of units who when activated will try and activate this unit

View File

@ -121,6 +121,19 @@ let processUploading (job: UserJob, botConfig: Funogram.Types.BotConfig, config:
async { async {
let ctx = getContext job let ctx = getContext job
let instrumentalPath, vocalsPath = getArtifactsPath ctx let instrumentalPath, vocalsPath = getArtifactsPath ctx
let sizeCheck = [
FileInfo(instrumentalPath)
FileInfo(vocalsPath) ]
|> List.map (fun x -> Math.Floor(double(x.Length) / double(Math.Pow(1024, 2))))
|> List.fold (fun acc x -> acc && x < double(50)) true
match sizeCheck with
| false ->
do! TgClient.makeRequestAsync botConfig <| Api.sendMessage ctx.chatId "Не могу загрузить результаты - они весят больше 50мб"
|> Async.Ignore
return { job with State = JobState.CleanUp }
| true ->
use fInstrumental = File.OpenRead instrumentalPath use fInstrumental = File.OpenRead instrumentalPath
use fVocals = File.OpenRead vocalsPath use fVocals = File.OpenRead vocalsPath