Compare commits

..

No commits in common. "d11fa31023423115c18f93b14193840042f203cc" and "08a36d8165ef9f66df48725cabb36429968ebb89" have entirely different histories.

3 changed files with 8 additions and 23 deletions

View file

@ -199,7 +199,7 @@ type Format struct {
ManifestURL *string `json:"manifest_url,omitempty"` ManifestURL *string `json:"manifest_url,omitempty"`
Language *Language `json:"language"` Language *Language `json:"language"`
Preference interface{} `json:"preference"` Preference interface{} `json:"preference"`
Quality *float64 `json:"quality,omitempty"` Quality *int64 `json:"quality,omitempty"`
HasDRM *bool `json:"has_drm,omitempty"` HasDRM *bool `json:"has_drm,omitempty"`
SourcePreference *int64 `json:"source_preference,omitempty"` SourcePreference *int64 `json:"source_preference,omitempty"`
ASR *int64 `json:"asr"` ASR *int64 `json:"asr"`

View file

@ -239,10 +239,6 @@ func (d *archiveFile) loadMore(ctx context.Context, to int64) error {
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
return fmt.Errorf("error copying from archive file reader: %w", err) return fmt.Errorf("error copying from archive file reader: %w", err)
} }
_, err = d.buffer.Seek(d.offset, io.SeekStart)
if err != nil {
return fmt.Errorf("failed to seek to start of the file: %w", err)
}
return nil return nil
} }
@ -256,7 +252,6 @@ func (d *archiveFile) Read(ctx context.Context, p []byte) (n int, err error) {
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
return n, fmt.Errorf("failed to read from buffer: %w", err) return n, fmt.Errorf("failed to read from buffer: %w", err)
} }
d.offset += int64(n)
return n, nil return n, nil
} }
@ -297,12 +292,12 @@ func ZipLoader(ctx context.Context, ctxreader ctxio.ReaderAt, size int64) (map[s
zr, err := zip.NewReader(reader, size) zr, err := zip.NewReader(reader, size)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create zip reader: %w", err) return nil, err
} }
rc, err := zr.File[i].Open() rc, err := zr.File[i].Open()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open file in zip archive: %w", err) return nil, err
} }
return rc, nil return rc, nil

View file

@ -4,6 +4,7 @@ import (
"archive/zip" "archive/zip"
"bytes" "bytes"
"context" "context"
"io"
"testing" "testing"
"git.kmsign.ru/royalcat/tstor/src/vfs" "git.kmsign.ru/royalcat/tstor/src/vfs"
@ -58,24 +59,13 @@ func TestZipFilesystem(t *testing.T) {
require.Equal("1.txt", e.Name()) require.Equal("1.txt", e.Name())
require.NotNil(e) require.NotNil(e)
out := make([]byte, 5) out := make([]byte, 11)
f, err := zfs.Open(ctx, "/path/to/test/file/1.txt") f, err := zfs.Open(ctx, "/path/to/test/file/1.txt")
require.NoError(err) require.NoError(err)
n, err := f.Read(ctx, out) n, err := f.Read(ctx, out)
require.NoError(err) require.Equal(io.EOF, err)
require.Equal(5, n) require.Equal(11, n)
require.Equal([]byte("Hello"), out) require.Equal(fileContent, out)
outSpace := make([]byte, 1)
n, err = f.Read(ctx, outSpace)
require.NoError(err)
require.Equal(1, n)
require.Equal([]byte(" "), outSpace)
n, err = f.Read(ctx, out)
require.NoError(err)
require.Equal(5, n)
require.Equal([]byte("World"), out)
} }