aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 10:05:42 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-31 10:05:42 +0300
commit8c20aaa30d2ca7483e56c2a3cb95e83a051013ea (patch)
tree9211a4dca7cad17db44089014e54faba9b3dca75 /telegram/handlers.go
parentf052d633ac722371271c4d621fa3046c4201956f (diff)
Fix links to not-yet-downloaded files
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go
index cf8b3d8..63f981f 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -1,7 +1,6 @@
package telegram
import (
- "crypto/sha256"
"fmt"
"os"
"path/filepath"
@@ -192,7 +191,10 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
// download file(s)
if file != nil && !file.Local.IsDownloadingCompleted {
- c.DownloadFile(file.Id, 10, false)
+ newFile, err := c.DownloadFile(file.Id, 10, true)
+ if err == nil {
+ file = newFile
+ }
}
// OTR support (I do not know why would you need it, seriously)
if !strings.HasPrefix(text, "?OTR") {
@@ -254,12 +256,7 @@ func (c *Client) updateFile(update *client.UpdateFile) {
err := os.Symlink(
update.File.Local.Path,
- fmt.Sprintf(
- "%s/%s%s",
- c.content.Path,
- fmt.Sprintf("%x", sha256.Sum256([]byte(update.File.Remote.Id))),
- filepath.Ext(update.File.Local.Path),
- ),
+ c.formatFilePath(c.content.Path, update.File.Remote.Id, filepath.Ext(update.File.Local.Path)),
)
if err != nil {
linkErr := err.(*os.LinkError)