Commit Graph

1003 Commits

Author SHA1 Message Date
Jarek Kowalski
8ff8ec0a36 snapshotfs: expose functions to round-trip between fs.Entry and DirEntry 2020-01-01 15:10:43 -08:00
Jarek Kowalski
503fa74be5 fs: added Directory.Child() method to look up children by name without necessarily loading all of them 2019-12-30 19:21:17 -08:00
Julio Lopez
194680adfc Refactor: relocate user/host helpers to userhost.go 2019-12-18 23:11:38 -08:00
Julio Lopez
0b7f30b6b4 rename cli/snapshot_utils.go -> cli/userhost.go 2019-12-18 23:11:38 -08:00
Jarek Kowalski
771fec1077 build: added simple Windows-based build script
This orchestrates building HTMLUI and main binary, only uses built-in shell script and avoids having any dependencies on Unix tools. Latest go and npm are required.
2019-12-18 19:35:40 -08:00
Julio Lopez
c8360ce6ca cleanup: fix linter errors
```
make lint
kopia/tools/.tools/bin/golangci-lint --deadline 180s run | tee .linterr.txt
cli/command_snapshot_delete.go:5: File is not `goimports`-ed with -local github.com/kopia/kopia (goimports)

tests/end_to_end_test/end_to_end_test.go:303: Function 'TestSnapshotDelete' is too long (187 > 100) (funlen)
func TestSnapshotDelete(t *testing.T) {
tests/end_to_end_test/end_to_end_test.go:306:2: only one cuddle assignment allowed before range statement (wsl)
	for _, tc := range []struct {
	^
tests/end_to_end_test/end_to_end_test.go:517:4: only one cuddle assignment allowed before if statement (wsl)
			if expectDeleteSucceeds {
			^
tests/end_to_end_test/end_to_end_test.go:537:2: assignments should only be cuddled with other assignments (wsl)
	line := lines[0]
	^
tests/end_to_end_test/end_to_end_test.go:542:2: only one cuddle assignment allowed before if statement (wsl)
	if typeVal != "policy" {
	^
tests/end_to_end_test/end_to_end_test.go:558:2: assignments should only be cuddled with other assignments (wsl)
	restoreDir := filepath.Join(e.dataDir, "restored")
	^
tests/end_to_end_test/end_to_end_test.go:568:2: if statements should only be cuddled with assignments (wsl)
	if got, want := len(si[0].snapshots), 1; got != want {
	^
tests/end_to_end_test/end_to_end_test.go:571:2: assignments should only be cuddled with other assignments (wsl)
	snapID := si[0].snapshots[0].snapshotID
	^
tests/end_to_end_test/end_to_end_test.go:604:2: if statements should only be cuddled with assignments (wsl)
	if len(fileInfo) != 0 {
	^
cli/command_snapshot_delete.go:25:2: only one cuddle assignment allowed before if statement (wsl)
	if err != nil {
	^
cli/command_snapshot_delete.go:36:3: if statements should only be cuddled with assignments (wsl)
		if labels["username"] != getUserName() {
		^
```
2019-12-18 18:17:15 -08:00
Jarek Kowalski
fc4675e6b6 htmlui: fixed sorting by path in snapshots view 2019-12-18 18:13:14 -08:00
Jarek Kowalski
313d326b45 htmlui: added elipsis in pagination bar for super long tables 2019-12-18 18:13:14 -08:00
Jarek Kowalski
495fc6deb1 htmlui: various UI tweaks
unified column ordering and sorting
switched to react-table v7 which allows seamless integration with bootstrap
2019-12-14 19:30:09 -08:00
Jarek Kowalski
c1454db2a9 makefile: added quick-install target which only rebuilds the binary and embeds pre-built HTMLUI 2019-12-14 19:30:09 -08:00
Jarek Kowalski
d9d4804dcb server: handle known UI routes specially by serving root index file 2019-12-14 13:10:32 -08:00
Jarek Kowalski
bd7a82ab94 makefile: added clean target 2019-12-14 10:48:31 -08:00
Jarek Kowalski
dbc820e972 htmlui: fixed npm vulnerability warnings 2019-12-14 10:19:08 -08:00
Jarek Kowalski
3a809f01e8 htmlui: added UI to browse contents of directories and download files 2019-12-14 10:19:08 -08:00
Jarek Kowalski
b93e58760a makefile: install and install-noui target 2019-12-14 10:19:08 -08:00
Jarek Kowalski
5d55568767 server: added /api/v1/objects/:id that retrieves contents of object given its ID 2019-12-14 10:19:08 -08:00
Nick
3f721aaf01 Snapshot restore command
Snapshot restore will take a snapshot ID and restore the
associated snapshot to the target path.
- Looks up the manifest with the snapshot ID
- Gets the snapshot root entry
- Copies the snapshot from the root entry to the target path

Because it uses the parent manifest with the copied permissions,
the restored directory will have the permissions of the original
source directory.
2019-12-13 06:18:50 -08:00
Nick
ae3d5610bf Dedicated snapshot delete command to delete by snap ID (#8)
Implemented snapshot delete command. Behaves similarly to manifest rm, but with extra verification steps. 
- Checks that the referenced manifest is of type "snapshot"
- Checks that the ID points to a snapshot, checks that the host name, user name, and path provided by flag or defaults match the source of the snapshot ID. Command will fail if they do not match, except if given --unsafe-ignore-source, which will bypass the associated safety requirement and delete anyway.

Added end to end tests for input combinations, restore in conjunction with delete, and trying to snapshot delete a manifest by ID of a non-snapshot manifest.
2019-12-12 18:02:48 -08:00
Julio Lopez
39a2cad2d9 Trivial/cleanup: remove unused type 2019-12-11 06:46:41 -08:00
Julio Lopez
9550c11aeb Add .gitignore for htmlui_bindata.go 2019-12-11 06:46:41 -08:00
Julio Lopez
7a34cb0a44 lint cleanup: add comments to exported symbols 2019-12-11 06:46:41 -08:00
Jarek Kowalski
2ba4e83cef moved all compression to separate package and sanitized identifiers 2019-12-10 23:25:28 -08:00
Jarek Kowalski
8ab93e0e2f addressed PR comments 2019-12-10 23:25:28 -08:00
Jarek Kowalski
9dd4e2aaf2 compression: added e2e test 2019-12-10 23:25:28 -08:00
Jarek Kowalski
c057e17379 compression: added support for min/max file sizes eligible for compression 2019-12-10 23:25:28 -08:00
Jarek Kowalski
c7be9cb45e upload: added support for uploading compressed objects based on policies 2019-12-10 23:25:28 -08:00
Jarek Kowalski
aec3cdcb2f object: added support for compressed objects 2019-12-10 23:25:28 -08:00
Jarek Kowalski
cfa2eea1e1 object: stop verifying object length in VerifyObject
With compression, the decompressed object length is
not known until we read the content.
2019-12-10 23:25:28 -08:00
Jarek Kowalski
a97b89662d policy: added compression policy 2019-12-10 23:25:28 -08:00
Jarek Kowalski
5ae2da4aea cli: added benchmark compression 2019-12-10 23:25:28 -08:00
Jarek Kowalski
58759551b3 compression: added object.Compressor object and some implementations 2019-12-10 23:25:28 -08:00
Julio Lopez
ca9ba27c6f Use github.com/natefinch/atomic.WriteFile in copyFileContents 2019-12-10 22:22:32 -08:00
Julio Lopez
cb850bc1ff Reformat help message constant to pacify lll linter 2019-12-10 22:22:32 -08:00
Julio Lopez
5396166505 Display diff when restored dir does not match source 2019-12-10 22:22:32 -08:00
Julio Lopez
d3f324f59b Add diff.compareEntry helper to compare attribute entries
- Use it to compare the entry attributes for all entry types.
  Allows comparing differences in file attributes among the
  contents of two directories. This is useful for verifying
  restored contents in end-to-end tests.

- Print message about modified entries only when both entries
  are files and they are being compared.
2019-12-10 22:22:32 -08:00
Julio Lopez
5c58b306a4 E2E test for snapshot restore command 2019-12-10 22:22:32 -08:00
Julio Lopez
820b29cbf2 FS hasher testing helper 2019-12-10 22:22:32 -08:00
Pavan Navarathna
fb57e828ad Restore command
Behavior:

- Creates top directory on restore
- Fails when target directories or files already exist
- Allows restoring to local root directory
- Restores of file attributes => mod time, mode, owner info
- Only a directory can be specified as a parameter

Not implemented:

- Restoring attributes of the top folder
- Restoring symlinks
- Restoring a single file
2019-12-10 22:22:32 -08:00
Julio Lopez
887a9180fa Trivial: fix imports grouping 2019-12-10 22:22:32 -08:00
Jarek Kowalski
f6d59608ab upload: require *policy.Tree for each upload 2019-12-07 14:24:57 -08:00
Jarek Kowalski
ece99073d4 policy: added sparse policy tree abstraction for quickly retrieving effective policies at runtime when walking a tree 2019-12-07 14:24:57 -08:00
Jarek Kowalski
b68ef7d781 refactored policy types and policy.Getter 2019-12-06 23:53:22 -08:00
Jarek Kowalski
095828b140 Makefile: fixed default rule 2019-11-30 13:00:40 -08:00
Jarek Kowalski
6217df1a87 lint: switched to 1.21 and fixed a ton of whitespace issues discovered
by new wsl linter
2019-11-26 06:49:49 -08:00
Jarek Kowalski
f4afaec9b5 object: fixed Seek() behavior for seeking to end of object 2019-11-25 23:36:24 -08:00
Julio Lopez
4598a05083 Trivial: clarify comment 2019-11-22 15:17:40 +09:00
Julio Lopez
41fb97bd45 Fix mispelled tag, caught by staticheck linter 2019-11-22 15:17:40 +09:00
Julio Lopez
24f292b719 Cleanup lint: empty lines (via whitespace and wsl linters) 2019-11-22 15:17:40 +09:00
Julio Lopez
4a24ae4714 Set golangci whitespace linter option 2019-11-22 15:17:40 +09:00
Pavan Navarathna
829742599c [#124] Add optional flags to override hostname and username 2019-11-22 15:15:21 +09:00