18

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.

  • Just an aside: some newer-OS android devices (I know specifically about Samsung S10) have LAN network transferring support built into the stock "file manager" app. If you share the folder on your computer, and know the computer IP address the phone can transfer over the LAN via WiFi – Yorik Jul 8 at 20:38
  • It could be heavily affected by the programs / devices making the copy. I mean local, or distant networks, but that sould be called upload / download operation. However, I was copying tons of files from / to a Terminal Server (through RDP), using \\tnsclient local share, and there were failures (I mean data corruption, without any error messages during copy). Sharing and attaching drives the old way solved the problem. The happened about the year 2010. – CLS Jul 23 at 8:18
35

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.

| improve this answer | |
  • Thank you very much. That's exactly what I wanted to know. And thanks to you I realized I should add a word "realistically" to my question, which I will do :P Can you also add this? When the file is copied between places or devices, how the process looks like, for example "creating a copy of the file in RAM, then moving from RAM to the destination"? And: If the moving process fails, the destination file gets deleted and the source doesn't get modified in any way? Asking for a confirmation. – lilKriT Jul 7 at 17:58
  • Thanks. Is it possible you can add that to your answer, for future readers? – lilKriT Jul 7 at 18:14
  • 1
    @lilKriT Answer updated as requested. – acejavelin Jul 7 at 18:18
  • 12
    Actually, your statement about moving files is not consistently accurate. I don't know about Windows specifically, but for a vast majority of systems, a move operation where the source and destination are on the same filesystem only touches metadata, updating only what directory the file is in. On such systems, the copy-then-delete approach is only used in cases where the move can't be done with only a metadata update (such as moving between two filesystems). – Austin Hemmelgarn Jul 8 at 1:51
  • 6
    @AustinHemmelgarn True, but the original question was about moving from drive to another, or more specifically from one device to another, thus my answer... I could update my answer but it isn't really relevant to the specific question. – acejavelin Jul 8 at 11:52
12

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.

| improve this answer | |
  • The answer isn't exactly what I was looking for, I'm asking more specifically about situation like I described. Copying file from one device to another files, what happens. However, the links sound very interesting, so thank you :) – lilKriT Jul 7 at 18:03
  • 3
    ECC RAM wouldn't do anything to protect the source files. For that you'd want a checksumming filesystem (and backups, of course). – Bob Jul 8 at 3:02
  • 1
    @Bob Well, if the file is on a RAM disk :) – Hagen von Eitzen Jul 8 at 10:20
  • 1
    @Bob It can help if the source file is dirty and scheduled for write back. Not very likely, but could happen if it has been recently downloaded and not yet synced to disk. – Oskar Skog Jul 8 at 19:26
9

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.

| improve this answer | |
  • 1
    "move, which is actually a copy-check-delete process" - really? Definitely not for a move on the same disk on Windows. – Thomas Weller Jul 8 at 17:42
  • 3
    move and or copy files from a computer to phone was the original query... – wb3 Jul 8 at 19:36
6

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.

| improve this answer | |
  • In even older media, floppy disks could get damaged during a read operation due to an already failing disk, like your hard disk scenario. It's not likely that many are still using that, though. I only know of businesses using ancient equipment they refuse to or can't replace still using removable magnetic media, unless it's backup tapes. And backup tapes could have this same issue, although they are reliable enough that the "lotto" chances also apply. And it's not likely the OP is using backup media for music storage. – computercarguy Jul 8 at 18:48
  • I've heard that floppy disks could also lose data if they were placed near something magnetic, like speakers, if they are strong enough. Is that possible? – lilKriT Jul 8 at 20:04
  • @lilKriT: sorry, I can't judge about that. It sounds plausible at first glance. But at the same time, the falloff is 1/r^3, so the magnetic field gets small very fast. – Thomas Weller Jul 9 at 5:13
  • That's what I thought. But if you would literally try to rub a floppy with a magnet, that could do it I think. – lilKriT Jul 11 at 3:08
  • I ran a long copy on an SSD a few years ago. The rather dusty drive controller overheated and the SSD data was corrupted. So I'd say only if the storage itself becomes damaged by the copy – mdoar Jul 23 at 23:01
4

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.

| improve this answer | |
0

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.

| improve this answer | |
  • Unfortunately, there's no option to change the default mode. I figured out setting it back and forth resets it, that's why I do it. And that's not even the end of weird stuff. If I use exactly the same cable (or any other) with adapter on USB-B slot - it works perfectly fine. It only happens with usb-c. At this point I'm thinking that it might be on windows side, making my phone "think" that "this is not a proper usb-c device" or something of that matter. – lilKriT Jul 9 at 1:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.