pentaradio-tools/upload.go

33 lines
847 B
Go
Raw Permalink Normal View History

2022-04-21 21:27:41 +02:00
/*******************************************************************************
* Copyright 2022 Stefan Majewsky <majewsky@gmx.net>
* SPDX-License-Identifier: GPL-3.0-only
* Refer to the file "LICENSE" for details.
*******************************************************************************/
package main
2022-04-21 21:54:59 +02:00
import (
"os"
"os/exec"
"strings"
)
2022-04-21 21:27:41 +02:00
func Upload(scan ScanResult) {
2022-04-21 21:54:59 +02:00
sftpCommands := []string{
"cd pentaradio/shownotes",
"put " + scan.ShowNotesFile(),
"cd ../chaptermarks",
"put " + scan.ChapterMarksFile(),
"cd ..",
}
for _, fileName := range scan.AudioFileNames {
sftpCommands = append(sftpCommands, "put "+fileName)
}
cmd := exec.Command("sftp", "-b", "-", "ftp.c3d2.de")
cmd.Stdin = strings.NewReader(strings.Join(sftpCommands, "\n") + "\n")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
must(cmd.Run())
2022-04-21 21:27:41 +02:00
}