Fix "invalid cross-device link" error when running on a different filesystem (#1769)
* fix cross-device rename errors * fallback to copy instead of always using it * use tmp dir in data folder * recreate tmp dir at startup
This commit is contained in:
@@ -20,7 +20,7 @@ func appendOfflineToVariantPlaylist(index int, playlistFilePath string) {
|
||||
}
|
||||
|
||||
tmpFileName := fmt.Sprintf("tmp-stream-%d.m3u8", index)
|
||||
atomicWriteTmpPlaylistFile, err := os.CreateTemp(os.TempDir(), tmpFileName)
|
||||
atomicWriteTmpPlaylistFile, err := os.CreateTemp(config.TempDir, tmpFileName)
|
||||
if err != nil {
|
||||
log.Errorln("error creating tmp playlist file to write to", playlistFilePath, err)
|
||||
return
|
||||
@@ -94,7 +94,7 @@ func createEmptyOfflinePlaylist(playlistFilePath string, offlineFilename string)
|
||||
|
||||
func saveOfflineClipToDisk(offlineFilename string) (string, error) {
|
||||
offlineFileData := static.GetOfflineSegment()
|
||||
offlineTmpFile, err := os.CreateTemp(os.TempDir(), offlineFilename)
|
||||
offlineTmpFile, err := os.CreateTemp(config.TempDir, offlineFilename)
|
||||
if err != nil {
|
||||
log.Errorln("unable to create temp file for offline video segment", err)
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
|
||||
}
|
||||
|
||||
// rename temp file
|
||||
if err := os.Rename(outputFileTemp, outputFile); err != nil {
|
||||
if err := utils.Move(outputFileTemp, outputFile); err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ func makeAnimatedGifPreview(sourceFile string, outputFile string) {
|
||||
if _, err := exec.Command("sh", "-c", ffmpegCmd).Output(); err != nil {
|
||||
log.Errorln(err)
|
||||
// rename temp file
|
||||
} else if err := os.Rename(outputFileTemp, outputFile); err != nil {
|
||||
} else if err := utils.Move(outputFileTemp, outputFile); err != nil {
|
||||
log.Errorln(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user