Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
# flock
|
|
|
|
[![TravisCI Build Status](https://img.shields.io/travis/gofrs/flock/master.svg?style=flat)](https://travis-ci.org/gofrs/flock)
|
|
|
|
[![GoDoc](https://img.shields.io/badge/godoc-go--flock-blue.svg?style=flat)](https://godoc.org/github.com/gofrs/flock)
|
|
|
|
[![License](https://img.shields.io/badge/license-BSD_3--Clause-brightgreen.svg?style=flat)](https://github.com/gofrs/flock/blob/master/LICENSE)
|
2019-04-10 09:41:22 -04:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/flock)](https://goreportcard.com/report/github.com/gofrs/flock)
|
Use the hashicorp/go-getter to download files
* removed packer.Cache and references since packer.Cache is never used except in the download step. The download step now uses the new func packer.CachePath(targetPath) for this, the behavior is the same.
* removed download code from packer that was reimplemented into the go-getter library: progress bar, http download restart, checksuming from file, skip already downloaded files, symlinking, make a download cancellable by context.
* on windows if packer is running without symlinking rights and we are getting a local file, the file will be copied instead to avoid errors.
* added unit tests for step_download that are now CI tested on windows, mac & linux.
* files are now downloaded under cache dir `sha1(filename + "?checksum=" + checksum) + file_extension`
* since the output dir is based on the source url and the checksum, when the checksum fails, the file is auto deleted.
* a download file is protected and locked by a file lock,
* updated docs
* updated go modules and vendors
2019-03-13 07:11:58 -04:00
|
|
|
|
|
|
|
`flock` implements a thread-safe sync.Locker interface for file locking. It also
|
|
|
|
includes a non-blocking TryLock() function to allow locking without blocking execution.
|
|
|
|
|
|
|
|
## License
|
|
|
|
`flock` is released under the BSD 3-Clause License. See the `LICENSE` file for more details.
|
|
|
|
|
|
|
|
## Go Compatibility
|
|
|
|
This package makes use of the `context` package that was introduced in Go 1.7. As such, this
|
|
|
|
package has an implicit dependency on Go 1.7+.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
```
|
|
|
|
go get -u github.com/gofrs/flock
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
```Go
|
|
|
|
import "github.com/gofrs/flock"
|
|
|
|
|
|
|
|
fileLock := flock.New("/var/lock/go-lock.lock")
|
|
|
|
|
|
|
|
locked, err := fileLock.TryLock()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
// handle locking error
|
|
|
|
}
|
|
|
|
|
|
|
|
if locked {
|
|
|
|
// do work
|
|
|
|
fileLock.Unlock()
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
For more detailed usage information take a look at the package API docs on
|
|
|
|
[GoDoc](https://godoc.org/github.com/gofrs/flock).
|