Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
fcddf624
Commit
fcddf624
authored
10 years ago
by
Kevin S. Hahn
Browse files
Options
Downloads
Patches
Plain Diff
adds option to keep data from bootstrap sort
- uses shutil.copy instead of shutil.move
parent
93231d60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bootstrap.py
+3
-1
3 additions, 1 deletion
bootstrap.py
util.py
+5
-2
5 additions, 2 deletions
util.py
with
8 additions
and
3 deletions
bootstrap.py
+
3
−
1
View file @
fcddf624
...
...
@@ -120,7 +120,7 @@ def sort(args):
with
open
(
filepath
,
'
rb
'
)
as
fd
:
for
chunk
in
iter
(
lambda
:
fd
.
read
(
1048577
*
hash_
.
block_size
),
''
):
hash_
.
update
(
chunk
)
status
,
detail
=
util
.
insert_file
(
db
.
acquisitions
,
None
,
None
,
filepath
,
hash_
.
hexdigest
(),
data_path
,
quarantine_path
)
status
,
detail
=
util
.
insert_file
(
db
.
acquisitions
,
None
,
None
,
filepath
,
hash_
.
hexdigest
(),
data_path
,
quarantine_path
,
args
.
keep
)
if
status
!=
200
:
print
detail
...
...
@@ -221,6 +221,7 @@ sort_parser = subparsers.add_parser(
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
)
sort_parser
.
add_argument
(
'
-q
'
,
'
--quick
'
,
action
=
'
store_true
'
,
help
=
'
omit computing of file checksums
'
)
sort_parser
.
add_argument
(
'
-k
'
,
'
--keep
'
,
action
=
'
store_true
'
,
help
=
'
do not remove the files after sorting
'
)
sort_parser
.
add_argument
(
'
db_uri
'
,
help
=
'
database URI
'
)
sort_parser
.
add_argument
(
'
path
'
,
help
=
'
filesystem path to data
'
)
sort_parser
.
add_argument
(
'
sort_path
'
,
help
=
'
filesystem path to sorted data
'
)
...
...
@@ -236,6 +237,7 @@ dbinitsort_parser.add_argument('db_uri', help='database URI')
dbinitsort_parser
.
add_argument
(
'
path
'
,
help
=
'
filesystem path to data
'
)
dbinitsort_parser
.
add_argument
(
'
sort_path
'
,
help
=
'
filesystem path to sorted data
'
)
dbinitsort_parser
.
add_argument
(
'
-q
'
,
'
--quick
'
,
action
=
'
store_true
'
,
help
=
'
omit computing of file checksums
'
)
dbinitsort_parser
.
add_argument
(
'
-k
'
,
'
--keep
'
,
action
=
'
store_true
'
,
help
=
'
do not remove the files after sorting
'
)
dbinitsort_parser
.
add_argument
(
'
-j
'
,
'
--json
'
,
help
=
'
JSON file container users and groups
'
)
dbinitsort_parser
.
add_argument
(
'
-f
'
,
'
--force
'
,
action
=
'
store_true
'
,
help
=
'
wipe out any existing db data
'
)
dbinitsort_parser
.
set_defaults
(
func
=
dbinitsort
)
...
...
This diff is collapsed.
Click to expand it.
util.py
+
5
−
2
View file @
fcddf624
...
...
@@ -15,7 +15,7 @@ import scitran.data
PROJECTION_FIELDS
=
[
'
timestamp
'
,
'
permissions
'
,
'
public
'
]
def
insert_file
(
dbc
,
_id
,
file_info
,
filepath
,
digest
,
data_path
,
quarantine_path
):
def
insert_file
(
dbc
,
_id
,
file_info
,
filepath
,
digest
,
data_path
,
quarantine_path
,
keep
=
False
):
filename
=
os
.
path
.
basename
(
filepath
)
if
_id
is
None
:
try
:
...
...
@@ -62,7 +62,10 @@ def insert_file(dbc, _id, file_info, filepath, digest, data_path, quarantine_pat
success
=
dbc
.
update
(
file_spec
,
{
'
$set
'
:
{
'
files.$
'
:
file_info
}})
if
not
success
[
'
updatedExisting
'
]:
dbc
.
update
({
'
_id
'
:
_id
},
{
'
$push
'
:
{
'
files
'
:
file_info
}})
shutil
.
move
(
filepath
,
container_path
+
'
/
'
+
filename
)
if
not
keep
:
shutil
.
move
(
filepath
,
container_path
+
'
/
'
+
filename
)
else
:
shutil
.
copy
(
filepath
,
container_path
+
'
/
'
+
filename
)
log
.
debug
(
'
Done %s
'
%
os
.
path
.
basename
(
filepath
))
# must use filepath, since filename is updated for sorted files
return
200
,
'
Success
'
...
...
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