Skip to content

Fix for deprecated ioutil #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/apply_lut.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"fmt"
"image/jpeg"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -103,7 +102,7 @@ var applyLutCmd = &cobra.Command{
}

if stat.IsDir() {
files, err := ioutil.ReadDir(input)
files, err := os.ReadDir(input)
if err != nil {
cui.Error(err.Error())
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/calendar.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -38,7 +37,7 @@ func splitSliceInChunks(a []string, chuckSize int) [][]string {

func getModDates(input string) ([]time.Time, error) {
modificationDates := []time.Time{}
items, err := ioutil.ReadDir(input)
items, err := os.ReadDir(input)
if err != nil {
return nil, err
}
Expand All @@ -50,7 +49,11 @@ func getModDates(input string) ([]time.Time, error) {
}
modificationDates = append(modificationDates, m...)
} else {
fileDate := item.ModTime()
fileInfo, err := item.Info()
if err != nil {
return nil, err
}
fileDate := fileInfo.ModTime()
parsedDate := time.Date(fileDate.Year(), fileDate.Month(), fileDate.Day(), 0, 0, 0, 0, fileDate.Location())
if !slices.Contains(modificationDates, parsedDate) {
modificationDates = append(modificationDates, parsedDate)
Expand Down
3 changes: 1 addition & 2 deletions cmd/export_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/csv"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -101,7 +100,7 @@ var exportTags = &cobra.Command{
}

if stat.IsDir() {
files, err := ioutil.ReadDir(input)
files, err := os.ReadDir(input)
if err != nil {
cui.Error(err.Error())
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/android/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package android

import (
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -31,7 +30,7 @@ var (
)

func prepare(out string, deviceFileName string, deviceModel string, mediaDate string, sortOptions utils.SortOptions, deviceFileReader io.ReadCloser, progressBar *mpb.Progress) (*mpb.Bar, string, error) {
localFile, err := ioutil.TempFile(out, deviceFileName)
localFile, err := os.CreateTemp(out, deviceFileName)
if err != nil {
return nil, "", err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/dji/dji.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dji

import (
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -69,7 +68,7 @@ func (Entrypoint) Import(params utils.ImportParams) (*utils.Result, error) {
root := filepath.Join(params.Input, "DCIM")
var result utils.Result

folders, err := ioutil.ReadDir(root)
folders, err := os.ReadDir(root)
if err != nil {
result.Errors = append(result.Errors, err)
return &result, nil
Expand Down
3 changes: 1 addition & 2 deletions pkg/dji/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dji
import (
"bufio"
"io"
"io/ioutil"
"os"
"regexp"
"strconv"
Expand Down Expand Up @@ -58,7 +57,7 @@ func fromSRT(srtPath string) (*utils.Location, error) {
defer fs.Close()
reader := bufio.NewReader(fs)
limitedSizeReader := io.LimitReader(reader, 2048)
content, err := ioutil.ReadAll(limitedSizeReader)
content, err := io.ReadAll(limitedSizeReader)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/dji/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dji
import (
"context"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -38,7 +37,7 @@ func TestParseSRT(t *testing.T) {

remoteFile, err := fs.Open(walk.Path())
require.NoError(t, err)
localFile, err := ioutil.TempFile(".", walk.Path())
localFile, err := os.CreateTemp(".", walk.Path())
require.NoError(t, err)
defer os.Remove(localFile.Name())

Expand Down
5 changes: 2 additions & 3 deletions pkg/gopro/gopro.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -129,7 +128,7 @@ func importFromGoProV2(params utils.ImportParams) utils.Result {
fileTypes := FileTypeMatches[V2]
var result utils.Result

folders, err := ioutil.ReadDir(params.Input)
folders, err := os.ReadDir(params.Input)
if err != nil {
result.Errors = append(result.Errors, err)
return result
Expand Down Expand Up @@ -307,7 +306,7 @@ func importFromGoProV1(params utils.ImportParams) utils.Result {
fileTypes := FileTypeMatches[V1]
var result utils.Result

folders, err := ioutil.ReadDir(params.Input)
folders, err := os.ReadDir(params.Input)
if err != nil {
result.Errors = append(result.Errors, err)
return result
Expand Down
3 changes: 1 addition & 2 deletions pkg/gopro/location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gopro
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -46,7 +45,7 @@ func TestParseGPMF(t *testing.T) {

remoteFile, err := fs.Open(walk.Path())
require.NoError(t, err)
localFile, err := ioutil.TempFile(".", walk.Path())
localFile, err := os.CreateTemp(".", walk.Path())
require.NoError(t, err)
defer os.Remove(localFile.Name())

Expand Down
2 changes: 1 addition & 1 deletion pkg/gopro/mp4parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (*HMMT) GetType() mp4.BoxType {
func (h *HMMT) GetFieldLength(name string, ctx mp4.Context) uint {
_ = name
_ = ctx
return uint(h.Count)
return uint(h.Count) //nolint:gosec // signed to unsigned is fine.
}

func GetHiLights(path string) (*HiLights, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/insta360/insta360.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package insta360
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -66,7 +65,7 @@ func (Entrypoint) Import(params utils.ImportParams) (*utils.Result, error) {
root := filepath.Join(params.Input, "DCIM")
var result utils.Result

folders, err := ioutil.ReadDir(root)
folders, err := os.ReadDir(root)
if err != nil {
result.Errors = append(result.Errors, err)
return &result, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/videomanipulation/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package videomanipulation

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -68,7 +68,7 @@ func (v *VMan) merge(output string, bar *mpb.Bar, ffConfig FFConfig, videos ...s
ffConfig.InArgs = append(ffConfig.InArgs, []string{"-hwaccel", "cuda"}...)
}

file, err := ioutil.TempFile(filepath.Dir(videos[0]), "filelist.*.txt")
file, err := os.CreateTemp(filepath.Dir(videos[0]), "filelist.*.txt")
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func (v *VMan) ExtractGPMF(input string) (*[]byte, error) {
defer wg.Done()
defer r.Close()

data, err := ioutil.ReadAll(r)
data, err := io.ReadAll(r)
extractData <- data
extractError <- err
}()
Expand Down