-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix WebDAV spelling, remove some inconsistencies (#143)
* Simplify logging, fix WebDAV spelling * Define options types per package * Move util functions that are not used cross package * Add per file license headers * Rename config type
- Loading branch information
Showing
10 changed files
with
307 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
# Ignore everything | ||
* | ||
|
||
# Exceptions: | ||
# Note: Wildcards for directories like * or ** don't work (yet) with exclamation marks! | ||
|
||
!cmd/backup/*.go | ||
!cmd/backup/*.tmpl | ||
|
||
!internal/storage/*.go | ||
!internal/storage/local/*.go | ||
!internal/storage/s3/*.go | ||
!internal/storage/ssh/*.go | ||
!internal/storage/webdav/*.go | ||
!internal/utilities/*.go | ||
|
||
!Dockerfile | ||
!entrypoint.sh | ||
!go.* | ||
test | ||
.github | ||
.circleci | ||
docs | ||
.editorconfig | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2022 - Offen Authors <[email protected]> | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
var noop = func() error { return nil } | ||
|
||
// remove removes the given file or directory from disk. | ||
func remove(location string) error { | ||
fi, err := os.Lstat(location) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return nil | ||
} | ||
return fmt.Errorf("remove: error checking for existence of `%s`: %w", location, err) | ||
} | ||
if fi.IsDir() { | ||
err = os.RemoveAll(location) | ||
} else { | ||
err = os.Remove(location) | ||
} | ||
if err != nil { | ||
return fmt.Errorf("remove: error removing `%s`: %w", location, err) | ||
} | ||
return nil | ||
} | ||
|
||
// buffer takes an io.Writer and returns a wrapped version of the | ||
// writer that writes to both the original target as well as the returned buffer | ||
func buffer(w io.Writer) (io.Writer, *bytes.Buffer) { | ||
buffering := &bufferingWriter{buf: bytes.Buffer{}, writer: w} | ||
return buffering, &buffering.buf | ||
} | ||
|
||
type bufferingWriter struct { | ||
buf bytes.Buffer | ||
writer io.Writer | ||
} | ||
|
||
func (b *bufferingWriter) Write(p []byte) (n int, err error) { | ||
if n, err := b.buf.Write(p); err != nil { | ||
return n, fmt.Errorf("(*bufferingWriter).Write: error writing to buffer: %w", err) | ||
} | ||
return b.writer.Write(p) | ||
} |
Oops, something went wrong.