D
D
darst2020-05-14 10:27:49
go
darst, 2020-05-14 10:27:49

How to know that a file on the server has changed without downloading the file itself?

Hello. How can go tell if a file on the server has changed without downloading the file itself to the local machine. Because a file can weigh both 2 kb and 2 gb and uploading an unmodified file every time is not good.

1. Comparison of file sizes will not work. Because inside they can be different.
2. Comparison by creation time will not work either.

3. There is an option to download n bytes and compare the hash with the same amount from the local file.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Shitskov, 2020-05-14
@Zarom

The most reliable way is when uploading a file to a remote server, apply a hash sum to it (or calculate it on the server automatically after uploading). Then, to check the fact that the file has changed, it is enough to check the hash sums of the remote and local files.

A
antonwx, 2020-05-14
@antonwx

3. There is an option to download n bytes and compare the hash with the same amount from the local file.

What if the change happened after these N bytes?
IMHO the most reliable is to check the date and size + in any case, download the file once in a while. Well, in general, it is best to do such a check on the server, if you have access to it.

X
xmoonlight, 2020-05-14
@xmoonlight

Bytes (in blocks) download from the server and read from the local disk.
Set a limit for byte-match validation.
And compare with each other:
1. Matched up to the limit - the files are the same, we interrupt the download.
2. No - download the updated file to the end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question