filedepot 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -14
- data/lib/filedepot/cli.rb +29 -9
- data/lib/filedepot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 388855a9c630053b59828d4c8c2a670b39dc7c5fbb00c73df92ce4058df14af4
|
|
4
|
+
data.tar.gz: a8edba521b0a2a55f5b82758bfb0479724bf15c23f1c8680092e4d5a680b90a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f91dbeda5d359022027732bda33232574b0a431820f0b9d85bb2c7025f4bd7a64ed3d37b8e54f66b7f0d13c90afd7869a687a5de2ecef464d9e174738df0a597
|
|
7
|
+
data.tar.gz: 725a34e03095b9c226f2cc90fbb87c883a8e8d476a1439af6f5fab29fe52a147d6199282f8c61a400250da093de263ce83d572511a50dee1a222ebc5b45719ce
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FileDepot
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/filedepot)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Filedepot is a command-line tool that lets you efficiently synchronize different files between people using a remote server over SSH. Each file is identified by a **handle** — a stable name you choose. The system automatically keeps versions of every upload. Use `filedepot push HANDLE FILE` to upload; use `filedepot pull HANDLE` to download the latest version by default.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -56,23 +56,17 @@ You can specify a store other than default by passing `--store [name]` for every
|
|
|
56
56
|
On the server, use these commands to set up the folder for filedepot:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
# set group
|
|
59
|
+
# set group, eg. filedepot
|
|
60
60
|
groupadd filedepot
|
|
61
61
|
usermod -aG filedepot user # for evey user you want allow filedepot
|
|
62
62
|
|
|
63
|
-
# set folder
|
|
63
|
+
# set folder, eg. /data/filedepot
|
|
64
64
|
mkdir -p /data/filedepot
|
|
65
65
|
chown -R :filedepot /data/filedepot/
|
|
66
66
|
chmod 2775 /data/filedepot
|
|
67
67
|
setfacl -d -m g:filedepot:rwx /data/filedepot
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
For existing folders:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
setfacl -m g:filedepot:rwx /data/filedepot
|
|
74
|
-
```
|
|
75
|
-
|
|
76
70
|
## Commands
|
|
77
71
|
|
|
78
72
|
| Command | Description |
|
|
@@ -90,11 +84,11 @@ setfacl -m g:filedepot:rwx /data/filedepot
|
|
|
90
84
|
|
|
91
85
|
### Setup
|
|
92
86
|
|
|
93
|
-
Prompts for store name, type, host, username, base path, and optional public base URL.
|
|
87
|
+
Prompts for store name, type, host, username, base path, and optional public base URL. Then writes the config file .
|
|
94
88
|
|
|
95
89
|
### Config
|
|
96
90
|
|
|
97
|
-
Opens the config file in your
|
|
91
|
+
Opens the config file in your default editor.
|
|
98
92
|
|
|
99
93
|
### Push
|
|
100
94
|
|
|
@@ -125,11 +119,11 @@ Shows handle, remote base path, current version, updated-at datetime, and latest
|
|
|
125
119
|
|
|
126
120
|
### Delete
|
|
127
121
|
|
|
128
|
-
Deletes all versions of a handle, or a specific version with `--version N`.
|
|
122
|
+
Deletes all versions of a handle, or a specific version with `--version N`. Use `--yes` or `-y` to skip confirmation (for scripts).
|
|
129
123
|
|
|
130
124
|
### Test
|
|
131
125
|
|
|
132
|
-
Runs an end-to-end test: creates a temporary file, pushes it, deletes locally, pulls it back, deletes the handle.
|
|
126
|
+
Runs an end-to-end test: creates a temporary file, pushes it, deletes locally, pulls it back, deletes the handle.
|
|
133
127
|
|
|
134
128
|
## Testing
|
|
135
129
|
|
|
@@ -138,6 +132,17 @@ bundle install
|
|
|
138
132
|
bundle exec rake test
|
|
139
133
|
```
|
|
140
134
|
|
|
135
|
+
## Notes
|
|
136
|
+
|
|
137
|
+
### Why not using rsync?
|
|
138
|
+
|
|
139
|
+
- Keeps versions of every uploaded file and lets you download or delete specific versions when needed
|
|
140
|
+
- Supports multiple remote stores (configure several and switch with `--store`)
|
|
141
|
+
- Other store types can be implemented beyond SSH: the base logic lives in the Store base class; each store type implements the required methods — similar to how [FUSE (Filesystem in Userspace)](https://github.com/libfuse/libfuse) works with filesystems
|
|
142
|
+
- Once configured, commands are quick: `filedepot push HANDLE FILE` and `filedepot pull HANDLE`
|
|
143
|
+
- Files stay organized in folders by handle and version
|
|
144
|
+
- Useful commands include `filedepot versions HANDLE` for reports on versions, dates, and sizes, and `filedepot purge HANDLE` to remove old versions
|
|
145
|
+
|
|
141
146
|
## License
|
|
142
147
|
|
|
143
148
|
MIT
|
data/lib/filedepot/cli.rb
CHANGED
|
@@ -100,16 +100,29 @@ module Filedepot
|
|
|
100
100
|
first_type = store_types.keys.first
|
|
101
101
|
defaults = store_types[first_type][:config].transform_keys(&:to_s)
|
|
102
102
|
|
|
103
|
+
existing_stores = []
|
|
104
|
+
original_store_name = nil
|
|
103
105
|
if Config.exists?
|
|
104
106
|
config = Config.load
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
existing_stores = config["stores"] || []
|
|
108
|
+
default_store_name = config["default_store"]
|
|
109
|
+
store_to_reconfig = if default_store_name && existing_stores.any?
|
|
110
|
+
existing_stores.find { |s| (s["name"] || s[:name]) == default_store_name }
|
|
111
|
+
end
|
|
112
|
+
store_to_reconfig ||= existing_stores.first
|
|
113
|
+
|
|
114
|
+
if store_to_reconfig
|
|
115
|
+
original_store_name = (store_to_reconfig["name"] || store_to_reconfig[:name]).to_s
|
|
116
|
+
defaults["name"] = original_store_name
|
|
117
|
+
defaults["host"] = (store_to_reconfig["host"] || store_to_reconfig[:host]).to_s
|
|
118
|
+
defaults["username"] = (store_to_reconfig["username"] || store_to_reconfig[:username]).to_s
|
|
119
|
+
defaults["base_path"] = (store_to_reconfig["base_path"] || store_to_reconfig[:base_path]).to_s
|
|
120
|
+
defaults["public_base_url"] = (store_to_reconfig["public_base_url"] || store_to_reconfig[:public_base_url]).to_s
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if existing_stores.size > 1
|
|
124
|
+
puts "Reconfiguring default store: #{original_store_name} (other stores will be preserved)"
|
|
125
|
+
puts ""
|
|
113
126
|
end
|
|
114
127
|
end
|
|
115
128
|
|
|
@@ -143,9 +156,16 @@ module Filedepot
|
|
|
143
156
|
"public_base_url" => (public_base_url.empty? ? nil : public_base_url)
|
|
144
157
|
}.compact
|
|
145
158
|
|
|
159
|
+
new_stores = if existing_stores.any?
|
|
160
|
+
other_stores = existing_stores.reject { |s| (s["name"] || s[:name]) == (original_store_name || name) }
|
|
161
|
+
[store_hash] + other_stores
|
|
162
|
+
else
|
|
163
|
+
[store_hash]
|
|
164
|
+
end
|
|
165
|
+
|
|
146
166
|
config = {
|
|
147
167
|
"default_store" => name,
|
|
148
|
-
"stores" =>
|
|
168
|
+
"stores" => new_stores
|
|
149
169
|
}
|
|
150
170
|
|
|
151
171
|
FileUtils.mkdir_p(Config::CONFIG_DIR)
|
data/lib/filedepot/version.rb
CHANGED