Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
isoonline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Cederqvist
isoonline
Commits
12799a96
Commit
12799a96
authored
21 years ago
by
Per Cederqvist
Browse files
Options
Downloads
Patches
Plain Diff
(mk_iso): Once all files are backed up, fill the image
with the least backed up files.
parent
435b7fc6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mkiso.py
+39
-0
39 additions, 0 deletions
mkiso.py
with
39 additions
and
0 deletions
mkiso.py
+
39
−
0
View file @
12799a96
...
...
@@ -102,17 +102,52 @@ def mk_iso(DBH):
files
=
[]
acc
=
0
nr_files
=
0
exhausted
=
None
others_min
=
0
others_max
=
0
# Fetch more files until we fill the CD (ignoring the filesystem overhead).
while
acc
<=
capacity
*
2048
:
rows
=
cursor
.
fetchmany
()
if
len
(
rows
)
==
0
:
exhausted
=
nr_files
break
files
+=
rows
while
acc
<=
capacity
*
2048
and
nr_files
<
len
(
files
):
acc
+=
files
[
nr_files
][
3
]
nr_files
+=
1
if
exhausted
==
None
:
exhausted
=
0
else
:
# Fill the media with redundant copies of already backed up files.
cursor
.
execute
(
"
SELECT file.file_id, file.filename, file.dir_id,
"
"
file.size, file.md5sum, file.sha1sum,
"
"
count(contents.media) AS cnt
"
"
FROM file, contents, media
"
"
WHERE file.file_id = contents.file
"
"
AND contents.media = media.media_id
"
"
AND media.broken = 0
"
"
GROUP BY file.file_id
"
"
ORDER BY cnt, RAND()
"
)
while
acc
<=
capacity
*
2048
:
rows
=
cursor
.
fetchmany
()
if
len
(
rows
)
==
0
:
break
# Store the smallest and largest cnt field.
if
others_min
==
0
:
others_min
=
rows
[
0
][
-
1
]
others_max
=
rows
[
0
][
-
1
]
others_max
=
max
(
others_max
,
rows
[
0
][
-
1
])
# Forget the "cnt" field.
for
r
in
rows
:
files
.
append
(
r
[:
6
])
while
acc
<=
capacity
*
2048
and
nr_files
<
len
(
files
):
acc
+=
files
[
nr_files
][
3
]
nr_files
+=
1
# Discard more and more files until we have something that fits (not
# ignoring the overhead).
backtrack
=
4
...
...
@@ -139,6 +174,10 @@ def mk_iso(DBH):
# it is hardly worth the effort.
used
=
iso_size
(
bases
,
files
[:
min_files
],
media_id
)
print
"
Storing %d files. Margin: %d
"
%
(
min_files
,
capacity
-
used
)
if
exhausted
<
min_files
:
print
"
%d of the files are already stored on %d-%d CDs.
"
%
(
(
min_files
-
exhausted
),
others_min
,
others_max
)
raw_input
(
"
[CONFIRM]
"
)
run_mkisofs
(
bases
,
files
[:
min_files
],
media_id
)
...
...
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