From de508d17f2b8bebfe895df8c81a87aa058bb5313 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 20 Aug 2024 01:05:11 -0400 Subject: [PATCH] Fix edited entries (edited to have fewer lines than before) not being truncated during sync (regression from 88b7a6be6d915aeee1b3e4ba52248a428e41bc3c) --- sync/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sync/client.go b/sync/client.go index 3c7974a..8691e72 100644 --- a/sync/client.go +++ b/sync/client.go @@ -261,7 +261,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow // create local file var localFile *os.File - localFile, err = os.OpenFile(localEntryFullPath, os.O_CREATE|os.O_WRONLY, 0600) + localFile, err = os.OpenFile(localEntryFullPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) if err != nil { fmt.Println(core.AnsiError+"Sync failed - Unable to create local file:", err.Error()+core.AnsiReset) os.Exit(core.ErrorWrite) @@ -318,7 +318,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow // create remote file var remoteFile *sftp.File - remoteFile, err = sftpClient.OpenFile(remoteEntryFullPath, os.O_CREATE|os.O_WRONLY) + remoteFile, err = sftpClient.OpenFile(remoteEntryFullPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY) if err != nil { fmt.Println(core.AnsiError+"Sync failed - Unable to create remote file ("+remoteEntryFullPath+"):", err.Error()+core.AnsiReset) os.Exit(core.ErrorWrite)