Skip to content

Commit b813aec

Browse files
committed
Fix for deprecated ioutil
1 parent 0d8261e commit b813aec

File tree

12 files changed

+20
-26
lines changed

12 files changed

+20
-26
lines changed

cmd/apply_lut.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bufio"
55
"fmt"
66
"image/jpeg"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"regexp"
@@ -103,7 +102,7 @@ var applyLutCmd = &cobra.Command{
103102
}
104103

105104
if stat.IsDir() {
106-
files, err := ioutil.ReadDir(input)
105+
files, err := os.ReadDir(input)
107106
if err != nil {
108107
cui.Error(err.Error())
109108
}

cmd/calendar.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76
"strconv"
@@ -38,7 +37,7 @@ func splitSliceInChunks(a []string, chuckSize int) [][]string {
3837

3938
func getModDates(input string) ([]time.Time, error) {
4039
modificationDates := []time.Time{}
41-
items, err := ioutil.ReadDir(input)
40+
items, err := os.ReadDir(input)
4241
if err != nil {
4342
return nil, err
4443
}
@@ -50,7 +49,11 @@ func getModDates(input string) ([]time.Time, error) {
5049
}
5150
modificationDates = append(modificationDates, m...)
5251
} else {
53-
fileDate := item.ModTime()
52+
fileInfo, err := item.Info()
53+
if err != nil {
54+
return nil, err
55+
}
56+
fileDate := fileInfo.ModTime()
5457
parsedDate := time.Date(fileDate.Year(), fileDate.Month(), fileDate.Day(), 0, 0, 0, 0, fileDate.Location())
5558
if !slices.Contains(modificationDates, parsedDate) {
5659
modificationDates = append(modificationDates, parsedDate)

cmd/export_tags.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/csv"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109
"strings"
@@ -101,7 +100,7 @@ var exportTags = &cobra.Command{
101100
}
102101

103102
if stat.IsDir() {
104-
files, err := ioutil.ReadDir(input)
103+
files, err := os.ReadDir(input)
105104
if err != nil {
106105
cui.Error(err.Error())
107106
}

pkg/android/android.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package android
22

33
import (
44
"io"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"strings"
@@ -31,7 +30,7 @@ var (
3130
)
3231

3332
func prepare(out string, deviceFileName string, deviceModel string, mediaDate string, sortOptions utils.SortOptions, deviceFileReader io.ReadCloser, progressBar *mpb.Progress) (*mpb.Bar, string, error) {
34-
localFile, err := ioutil.TempFile(out, deviceFileName)
33+
localFile, err := os.CreateTemp(out, deviceFileName)
3534
if err != nil {
3635
return nil, "", err
3736
}

pkg/dji/dji.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dji
22

33
import (
4-
"io/ioutil"
54
"log"
65
"os"
76
"path/filepath"
@@ -69,7 +68,7 @@ func (Entrypoint) Import(params utils.ImportParams) (*utils.Result, error) {
6968
root := filepath.Join(params.Input, "DCIM")
7069
var result utils.Result
7170

72-
folders, err := ioutil.ReadDir(root)
71+
folders, err := os.ReadDir(root)
7372
if err != nil {
7473
result.Errors = append(result.Errors, err)
7574
return &result, nil

pkg/dji/location.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dji
33
import (
44
"bufio"
55
"io"
6-
"io/ioutil"
76
"os"
87
"regexp"
98
"strconv"
@@ -58,7 +57,7 @@ func fromSRT(srtPath string) (*utils.Location, error) {
5857
defer fs.Close()
5958
reader := bufio.NewReader(fs)
6059
limitedSizeReader := io.LimitReader(reader, 2048)
61-
content, err := ioutil.ReadAll(limitedSizeReader)
60+
content, err := io.ReadAll(limitedSizeReader)
6261
if err != nil {
6362
return nil, err
6463
}

pkg/dji/location_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dji
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"strings"
98
"testing"
@@ -38,7 +37,7 @@ func TestParseSRT(t *testing.T) {
3837

3938
remoteFile, err := fs.Open(walk.Path())
4039
require.NoError(t, err)
41-
localFile, err := ioutil.TempFile(".", walk.Path())
40+
localFile, err := os.CreateTemp(".", walk.Path())
4241
require.NoError(t, err)
4342
defer os.Remove(localFile.Name())
4443

pkg/gopro/gopro.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io/ioutil"
87
"log"
98
"os"
109
"path/filepath"
@@ -129,7 +128,7 @@ func importFromGoProV2(params utils.ImportParams) utils.Result {
129128
fileTypes := FileTypeMatches[V2]
130129
var result utils.Result
131130

132-
folders, err := ioutil.ReadDir(params.Input)
131+
folders, err := os.ReadDir(params.Input)
133132
if err != nil {
134133
result.Errors = append(result.Errors, err)
135134
return result
@@ -307,7 +306,7 @@ func importFromGoProV1(params utils.ImportParams) utils.Result {
307306
fileTypes := FileTypeMatches[V1]
308307
var result utils.Result
309308

310-
folders, err := ioutil.ReadDir(params.Input)
309+
folders, err := os.ReadDir(params.Input)
311310
if err != nil {
312311
result.Errors = append(result.Errors, err)
313312
return result

pkg/gopro/location_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package gopro
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"testing"
98

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

4746
remoteFile, err := fs.Open(walk.Path())
4847
require.NoError(t, err)
49-
localFile, err := ioutil.TempFile(".", walk.Path())
48+
localFile, err := os.CreateTemp(".", walk.Path())
5049
require.NoError(t, err)
5150
defer os.Remove(localFile.Name())
5251

pkg/gopro/mp4parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (*HMMT) GetType() mp4.BoxType {
2727
func (h *HMMT) GetFieldLength(name string, ctx mp4.Context) uint {
2828
_ = name
2929
_ = ctx
30-
return uint(h.Count)
30+
return uint(h.Count) //nolint:gosec // signed to unsigned is fine.
3131
}
3232

3333
func GetHiLights(path string) (*HiLights, error) {

pkg/insta360/insta360.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package insta360
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"os"
98
"path/filepath"
@@ -66,7 +65,7 @@ func (Entrypoint) Import(params utils.ImportParams) (*utils.Result, error) {
6665
root := filepath.Join(params.Input, "DCIM")
6766
var result utils.Result
6867

69-
folders, err := ioutil.ReadDir(root)
68+
folders, err := os.ReadDir(root)
7069
if err != nil {
7170
result.Errors = append(result.Errors, err)
7271
return &result, nil

pkg/videomanipulation/ffmpeg.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package videomanipulation
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66
"log"
77
"os"
88
"path/filepath"
@@ -68,7 +68,7 @@ func (v *VMan) merge(output string, bar *mpb.Bar, ffConfig FFConfig, videos ...s
6868
ffConfig.InArgs = append(ffConfig.InArgs, []string{"-hwaccel", "cuda"}...)
6969
}
7070

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

177-
data, err := ioutil.ReadAll(r)
177+
data, err := io.ReadAll(r)
178178
extractData <- data
179179
extractError <- err
180180
}()

0 commit comments

Comments
 (0)