Posts: 4,560
Threads: 1,464
Joined: Sep 2016
i have a big file to copy. it could be a binary file. i have the source and target filenames. i might like to also show a progress bar. the file could be larger than RAM. what is the best and safest way to copy it? what is the best way to verify it was copied uncorrupted?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
(Aug-26-2019, 07:36 PM)Larz60+ Wrote: On Linux, use rsync
how to do it within python with the progress handled by that code.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
Sep-02-2019, 08:26 PM
(This post was last modified: Sep-02-2019, 08:26 PM by Skaperen.)
nice article. but my need gives rsync no advantage. the target does not yet exist. this is an in-host copy of a very large file such as a movie video. it may be copying between two different filesystems. it may be doing a first-time full backup (even rsync has to do this the first time). i am wondering how good copy code determines what is a good chunk size to better manage memory load, or if it uses
(some module).sendfile()
and how.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
i've used rsync and many other programs. i have made code that does copying in many languages. and i know i did it right in C and Pike. i want to also do it in Python. i am not interested in calling some program to do it. i want to know if this is appropriate or what.
while True:
data = input_file.read(buffer_size)
if not data:
break
output_file.write(data)
it would be a bad idea to call .read() without a size. the file might be larger than ram+swap.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.