TransWikia.com

Can original file get corrupted during copying?

Super User Asked on November 20, 2021

I was copying music from my computer to a phone using usb-c cable, and because of stupid reasons, the copying process failed.
(In short, turns out a new phone requires some dancing around bonfire for the file transfer to work).
First 4 songs copied fine, 5th song – process failed, had to start over. That inspired me to ask this question.

So just out of curiosity – is there any realistic (meaning, bigger than winning the lottery on a warm day, with full moon) chance that the original files on my computer could get corrupted because copying process failed for any reason? Bonus question, what would happen if I would be moving the files instead of copying?

Edit: (feel free to skip if you’re not interested in the cable situation)

Many people mention the copying situation so here’s what happened.
New phone came with USB-C cable by default. I tried using it with my USB-C laptop port. The phone disconnects randomly, usually after few seconds, so I can’t even browse the files, much less copy them. After playing around with it, the connection lasted long enough for me to feel safe enough, so I started copying music from laptop to the phone. It failed after a few songs, hence my question)

After many tests with other devices and adapters, this is the result. Phone’s usb-c port works perfectly fine (charging with different cables, and using a pendrive with adapter works).
laptops usb-c port works perfectly fine (tried the same pendrive with same adapter)
cable also works fine (it charges the phone without problem, and after THE FIX, it also transfers files). So…

The fix:

This new phone, when plugged to a computer shows these default settings(forgive me if my translation isn’t perfect):
controlling device: this phone (the other option is connected device)
usb mode: move files – auto android (other options are: charging only, usb router, move pictures and something else)
Turns out that what I need to do, is to switch mode to something else (I used "move pictures") and then BACK to "move files".
Meaning that the "default options" are not really "default"?

From then on, I could easily move pictures, music and even movies back and forth.
I even wanted to create a question how something like that is even possible, but I have to wait for 40 minutes.

6 Answers

Another possibility: in ext[234], if the filesystem is mounted with the atime option enabled, the inode (not the file) can be damaged. Maybe something similiar can happen in NTFS.

Answered by Martín-Blas Pérez Pinilla on November 20, 2021

Generally, copying wouldn't harm the original file.

It would be possible that the resulting file arrives corrupt, as a result of a transfer error, be that on the cable, the resulting device, a RAM error, etc.

However, even if when you read the source file into memory, it gets corrupted (and yes, that can corrupt your transfers every time), it should not touch the original file (it doesn't need to write back into disk what is already there).

Thomas makes a good point that while reading the file you may be changing its access time metadata, and that might lead to corruption (quite unlikely imho, and perhaps affecting a different file than the one being read)

It may be more probable that the data was already damaged, and it is only being noticed when you try to read it (which should then cause a copy error as well).

When compared with moving data, copying to a different device, the process will be copy + delete. Here there are two approaches here when dealing with multiple files: The program could copy all the files, then remove the source ones, or it could copy and delete each file as-it-goes (or even per-folder!). If the files are only deleted at the last step, there is no data loss. On the other hand, if the files were moved individually, you would not actually corrupt the files, but you would end up with only some of the files on each device.

When moving files on the same partition, you will actually be changing the pointer to the file data from one location (file path) to another, so the file contents shouldn't be expected to be corrupted, either (of course, if that pointer itself gets corrupted, that would be quite bad, although the risk of certain few bytes corrupting is quite small).

PS: Changing the mode back and forth is probably resetting the mode, this makes me think that it is not properly reset when connecting as it should. This may be solved in the future with a firmware upgrade. In the meantime you probably want to set a different mode as the default, so you only need to do a single switch.

Answered by Ángel on November 20, 2021

In your case, chances should be very low as other answers have already pointed out. However, it heavily depends on the media and the state of the media that is used. These are the cases that happened to me or my customers (or at least I believe it was):

  • CDs, DVDs and similar media: if you need to put the disk into the disk drive, you may place it incorrectly and it may get cracked, but still slip in. You might be able to copy a few files, but as the disk spins, the forces drag it apart and the disk breaks

  • USB Sticks: when plugged in near a fan, warm air heats up the USB stick. It might die because of overheating while copying.

  • Already damaged hard disk: a hard disk that has bad SMART data or makes uncommon noise might fully break down while trying to rescue data from the drive.

  • Old flash media: Since the operating system might want to update the MAC timestamp (especially A for access) of a file, it needs to write to the disk. If that write operation causes a block to fail, stuff becomes interesting.

Other than that, data loss while writing is much more common, IMHO. Typically with sudden power loss or people turning off the PC in a forced way.

is there any realistic (meaning, bigger than winning the lottery on a warm day, with full moon) chance that the original files on my computer could get corrupted because copying process failed for any reason?

IMHO, yes. I was a single-person company (22 years), so I haven't had too many clients and still, I can name 4 cases. Definitely higher chance than lottery. Or all my clients were totally "lucky".

what would happen if I would be moving the files instead of copying?

Slightly higher chance, since deleting the file will result in a write operation.

Answered by Thomas Weller on November 20, 2021

The chance that the original file would be corrupted, any more than any other read operation would corrupt a file, is infinitesimally small. Most file corruption happens during a write, and is usually combined with a power or hardware issue. Same thing with a move, which is actually a copy-check-delete process.

Answered by wb3 on November 20, 2021

Is there any chance that the original files on my computer could get corrupted because copying process failed for any reason?

Any chance? Yes, but it's more likely that you get struck by lightning while being bitten by a shark... Theoretically it could happen, but the chance is so low it is realistically impossible as the original file is only read and not written to. That does not mean some other thing couldn't corrupt a file while the copy was in process, such as a failing HDD, RAM, or being read/written by another process.

What would happen if I would be moving the files instead of copying?

When moving a file, a copy process occurs first, then when the copy is considered to be successful, the original file is deleted. It doesn't copy 12% of the file, fail, then delete 12% of the original file. It is more likely for corruption to occur doing this, but not significantly more.

Honestly, I would look into TeraCopy or similar utilities... It is a replacement for Window's copy utility which has the added ability to verify the destination file(s) after a copy process.

EDIT: Added for clarity to the question being updated.

The copy process varies slightly based on the application, but it is essentially read into RAM in chunks of varying size, then written to the destination file in chunks until the process is complete. How big the "blocks" are varies by application, file size, available RAM, etc. In a move processes, it also varies by application, but most leave the partial/failed file at the destination but leave the source file untouched. Note that when files are moved within the same partition, most modern operating systems are smart enough to just update it's "location" metadata, rather than actually move the data. This method can be significantly faster and more reliable than an actual copy/delete process.

Answered by acejavelin on November 20, 2021

Is there any chance that the original files on my computer could get corrupted

There is a small chance that files could get corrupted at any time (not just while copying).

To mitigate the risks you can do things like make sure you are using ECC memory and also perform checksums before and after a copy (or do a complete bitwise compare of the two copies).

There is an interesting discussion here, statistics - Cosmic Rays: what is the probability they will affect a program? - Stack Overflow, where the answers discuss the probability of random corruption and what can be done to prevent it.

Soft error - Wikipedia is also worth a read.

Answered by DavidPostill on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP