Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Poulpe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
octobus
Poulpe
Commits
bae90786
Commit
bae90786
authored
3 years ago
by
Simon Sapin
Browse files
Options
Downloads
Patches
Plain Diff
Create tar archives
parent
a5a4311d
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Initial implementation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+48
-0
48 additions, 0 deletions
Cargo.lock
Cargo.toml
+1
-0
1 addition, 0 deletions
Cargo.toml
src/main.rs
+25
-5
25 additions, 5 deletions
src/main.rs
with
74 additions
and
5 deletions
Cargo.lock
+
48
−
0
View file @
bae90786
...
...
@@ -29,6 +29,12 @@
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -75,6 +81,18 @@
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "filetime"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"winapi",
]
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -110,6 +128,7 @@
dependencies = [
"dialoguer",
"structopt",
"tar",
]
[[package]]
...
...
@@ -161,6 +180,15 @@
]
[[package]]
name = "redox_syscall"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -217,6 +245,17 @@
]
[[package]]
name = "tar"
version = "0.4.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c"
dependencies = [
"filetime",
"libc",
"xattr",
]
[[package]]
name = "terminal_size"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
...
...
@@ -286,3 +325,12 @@
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "xattr"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
dependencies = [
"libc",
]
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
0
View file @
bae90786
...
...
@@ -10,3 +10,4 @@
[dependencies]
dialoguer
=
{
version
=
"0.9"
,
default-features
=
false
}
structopt
=
"0.3"
tar
=
"0.4"
This diff is collapsed.
Click to expand it.
src/main.rs
+
25
−
5
View file @
bae90786
use
dialoguer
::
console
::
style
;
use
dialoguer
::
Confirm
;
use
std
::
path
::
Path
;
use
std
::
path
::
PathBuf
;
use
structopt
::
StructOpt
;
#[derive(StructOpt)]
enum
Args
{
...
...
@@ -3,9 +4,9 @@
use
std
::
path
::
PathBuf
;
use
structopt
::
StructOpt
;
#[derive(StructOpt)]
enum
Args
{
NewDataset
{
directory
:
String
},
NewDataset
{
directory
:
PathBuf
},
}
struct
Megafine
{
...
...
@@ -15,6 +16,6 @@
type
Result
<
T
>
=
std
::
result
::
Result
<
T
,
Box
<
dyn
std
::
error
::
Error
>>
;
impl
Megafine
{
fn
new_dataset
(
&
self
,
directory
:
String
)
->
Result
<
()
>
{
fn
new_dataset
(
&
self
,
directory
:
&
Path
)
->
Result
<
()
>
{
println!
(
"Creating a dataset from directory {}"
,
...
...
@@ -19,7 +20,7 @@
println!
(
"Creating a dataset from directory {}"
,
style
(
&
directory
)
.bold
()
style
(
directory
.display
()
)
.bold
()
);
if
!
std
::
fs
::
metadata
(
&
directory
)
?
.is_dir
()
{
Err
(
"Not a directory"
)
?
}
...
...
@@ -22,7 +23,16 @@
);
if
!
std
::
fs
::
metadata
(
&
directory
)
?
.is_dir
()
{
Err
(
"Not a directory"
)
?
}
let
base_name
=
directory
.file_name
()
.ok_or
(
"No base name"
)
?
.to_str
()
.ok_or
(
"Non-Unicode base name"
)
?
;
let
archive_name
=
format!
(
"{}.tar"
,
base_name
);
println!
(
"About to create tmp/{}"
,
style
(
&
archive_name
)
.bold
());
let
proceed
=
Confirm
::
new
()
.with_prompt
(
"Continue?"
)
.default
(
false
)
...
...
@@ -30,7 +40,17 @@
if
!
proceed
{
Err
(
""
)
?
}
// TODO
let
archive_path
=
self
.tmp_dir
.join
(
&
archive_name
);
let
archive_file
=
std
::
fs
::
OpenOptions
::
new
()
.write
(
true
)
.create_new
(
true
)
.open
(
&
archive_path
)
?
;
let
mut
tar
=
tar
::
Builder
::
new
(
archive_file
);
tar
.follow_symlinks
(
false
);
tar
.append_dir_all
(
base_name
,
directory
)
?
;
tar
.into_inner
()
?
.sync_all
()
?
;
Ok
(())
}
...
...
@@ -63,7 +83,7 @@
fn
main
()
->
Result
<
()
>
{
let
megafine
=
Megafine
::
new
()
?
;
match
Args
::
from_args
()
{
Args
::
NewDataset
{
directory
}
=>
megafine
.new_dataset
(
directory
),
Args
::
NewDataset
{
directory
}
=>
megafine
.new_dataset
(
&
directory
),
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment