Compare commits
No commits in common. "d11fa31023423115c18f93b14193840042f203cc" and "08a36d8165ef9f66df48725cabb36429968ebb89" have entirely different histories.
d11fa31023
...
08a36d8165
3 changed files with 8 additions and 23 deletions
|
@ -199,7 +199,7 @@ type Format struct {
|
|||
ManifestURL *string `json:"manifest_url,omitempty"`
|
||||
Language *Language `json:"language"`
|
||||
Preference interface{} `json:"preference"`
|
||||
Quality *float64 `json:"quality,omitempty"`
|
||||
Quality *int64 `json:"quality,omitempty"`
|
||||
HasDRM *bool `json:"has_drm,omitempty"`
|
||||
SourcePreference *int64 `json:"source_preference,omitempty"`
|
||||
ASR *int64 `json:"asr"`
|
||||
|
|
|
@ -239,10 +239,6 @@ func (d *archiveFile) loadMore(ctx context.Context, to int64) error {
|
|||
if err != nil && err != io.EOF {
|
||||
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
|
||||
}
|
||||
|
@ -256,7 +252,6 @@ func (d *archiveFile) Read(ctx context.Context, p []byte) (n int, err error) {
|
|||
if err != nil && err != io.EOF {
|
||||
return n, fmt.Errorf("failed to read from buffer: %w", err)
|
||||
}
|
||||
d.offset += int64(n)
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create zip reader: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rc, err := zr.File[i].Open()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to open file in zip archive: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rc, nil
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/src/vfs"
|
||||
|
@ -58,24 +59,13 @@ func TestZipFilesystem(t *testing.T) {
|
|||
require.Equal("1.txt", e.Name())
|
||||
require.NotNil(e)
|
||||
|
||||
out := make([]byte, 5)
|
||||
out := make([]byte, 11)
|
||||
f, err := zfs.Open(ctx, "/path/to/test/file/1.txt")
|
||||
require.NoError(err)
|
||||
n, err := f.Read(ctx, out)
|
||||
require.NoError(err)
|
||||
require.Equal(5, n)
|
||||
require.Equal([]byte("Hello"), 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)
|
||||
require.Equal(io.EOF, err)
|
||||
require.Equal(11, n)
|
||||
require.Equal(fileContent, out)
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue