Skip to content

Commit de508d1

Browse files
committed
Fix edited entries (edited to have fewer lines than before) not being truncated during sync (regression from 88b7a6b)
1 parent f5a6350 commit de508d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sync/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow
261261

262262
// create local file
263263
var localFile *os.File
264-
localFile, err = os.OpenFile(localEntryFullPath, os.O_CREATE|os.O_WRONLY, 0600)
264+
localFile, err = os.OpenFile(localEntryFullPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
265265
if err != nil {
266266
fmt.Println(core.AnsiError+"Sync failed - Unable to create local file:", err.Error()+core.AnsiReset)
267267
os.Exit(core.ErrorWrite)
@@ -318,7 +318,7 @@ func sftpSync(sshClient *ssh.Client, sshEntryRoot string, sshIsWindows bool, dow
318318

319319
// create remote file
320320
var remoteFile *sftp.File
321-
remoteFile, err = sftpClient.OpenFile(remoteEntryFullPath, os.O_CREATE|os.O_WRONLY)
321+
remoteFile, err = sftpClient.OpenFile(remoteEntryFullPath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY)
322322
if err != nil {
323323
fmt.Println(core.AnsiError+"Sync failed - Unable to create remote file ("+remoteEntryFullPath+"):", err.Error()+core.AnsiReset)
324324
os.Exit(core.ErrorWrite)

0 commit comments

Comments
 (0)