Skip to content
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

file 2G.file: writing data: archive/tar: write too long #387

Closed
halfcrazy opened this issue Sep 20, 2023 · 1 comment · Fixed by #388
Closed

file 2G.file: writing data: archive/tar: write too long #387

halfcrazy opened this issue Sep 20, 2023 · 1 comment · Fixed by #388

Comments

@halfcrazy
Copy link
Contributor

halfcrazy commented Sep 20, 2023

What version of the package or command are you using?

github.com/mholt/archiver/v4 v4.0.0-alpha.8

What are you trying to do?

create an archive with continuous writing contents to the source file.

What steps did you take?

prepare data with dd if=/dev/urandom of=/2G.file bs=1M count=2048

open a new window, and run scripts

while true; do
    echo "data..." >> 2G.file
    sleep 0.1
done
package main

import (
	"context"
	"github.com/mholt/archiver/v4"
	"os"
)

func main() {

	files, err := archiver.FilesFromDisk(nil, map[string]string{
		"/2G.file": "",
	})
	if err != nil {
		panic(err)
	}

	// create the output file we'll write to
	tmpFileName := "/tmp/aa"
	out, err := os.Create(tmpFileName)
	if err != nil {
		panic(err)
	}
	defer out.Close()

	// we can use the CompressedArchive type to gzip a tarball
	// (compression is not required; you could use Tar directly)
	format := archiver.CompressedArchive{
		Compression: archiver.Gz{},
		Archival:    archiver.Tar{},
	}

	// create the archive
	err = format.Archive(context.Background(), out, files)
	if err != nil {
		panic(err)
	}
}

What did you expect to happen, and what actually happened instead?

Expect: no errors report
Actually: panic: file 2G.file: writing data: archive/tar: write too long

How do you think this should be fixed?

Please link to any related issues, pull requests, and/or discussion

#8

Bonus: What do you use archiver for, and do you find it useful?

My use case is to create a backup file for my living database.

halfcrazy added a commit to halfcrazy/archiver that referenced this issue Sep 20, 2023
halfcrazy added a commit to halfcrazy/archiver that referenced this issue Sep 21, 2023
mholt#387
Signed-off-by: Yan Zhu <hackzhuyan@gmail.com>
@mholt
Copy link
Owner

mholt commented Sep 21, 2023

Thanks for the PR! I left a comment since I need help understanding it better.

mholt added a commit that referenced this issue Dec 13, 2023
* Fix create archive to a continuous writing source file failed

#387
Signed-off-by: Yan Zhu <hackzhuyan@gmail.com>

* Update archiver.go

---------

Signed-off-by: Yan Zhu <hackzhuyan@gmail.com>
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants