aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
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)