TheLastGimbus / GooglePhotosTakeoutHelper

Script that organizes the Google Takeout archive into one big chronological folder
https://aur.archlinux.org/packages/gpth-bin
Apache License 2.0
3.48k stars 176 forks source link

Can't output files to different drive than input #251

Open flofly22 opened 9 months ago

flofly22 commented 9 months ago

Hi

I realized that gpth is crashing under windows if the output directory is on a different harddisk volume then the input directory.

flofly22 commented 9 months ago

Hi

I posted a bit too fast, here is some error message from the cmd

`Moving photos to output folder : ........................................ 0/215 Unhandled exception: FileSystemException: Cannot rename file to 'Y:\Google_Export\takeoutHelper\ALL_PHOTOS\2014\09\IMAG0726(1).jpg', path = 'Z:\15_Export\01_Google Fotos\takeout-20231001T073449Z\Takeout\Google Fotos\Photos from 2014\IMAG0726(1).jpg' (OS Error: The system cannot move the file to a different disk drive. , errno = 17)

0 _checkForErrorResponse (dart:io/common.dart:55)

1 _File.rename. (dart:io/file_impl.dart:335)

#2 moveFiles.moveFile (package:gpth/moving.dart:135) #3 moveFiles (package:gpth/moving.dart:140) #4 main. (file:///d:/a/googlephotostakeouthelper/googlephotostakeouthelper/bin/gpth.dart:373) ` Regards Florian
TheLastGimbus commented 9 months ago

Huuhh.....

Well i see it's a system/programming language error, so i can't do much about it... but you can just run directly on main drive - by default gpth moves the files, so it will use 0 extra space

eedbarr commented 9 months ago

Thank you for linking me to this issue. As a recap, I can save it in the same hard disk since gpth only moves them and not really copy. I will try that when I Get home.

Thank you!

peter-kraker commented 7 months ago

I'm getting the same error.

Googling the error, it seems like you can only rename files in Dart if they are on the same filesystem. The workaround is to use File.copy instead. You are renaming files using File.rename in moving.dart#135, but the previous line calls File.copy -- the ternary syntax there makes it hard to understand the logic: any way you could detect if the destination is on a different filesystem and call a different function accordingly?

I was not using the tool in the way you intended, but let me walk through my thinking: I assumed that you were copying full files around. I figured that you would leave the pictures in Google Takeout directory and copy the into a new directory. I didn't want to thrash my disk doing that (nor do I have that much free space), so I decided to use different drives for source and target -- I figured one disk would read while the other writes. One additional reason why I wanted to do that was to have a very clear source & destination in case anything went wrong -- I think I would prefer to leave the Google Takeout directory in-place in case I don't like the results of the TakeoutHelper.

Now that I understand that you're not moving the full content of the file, just "renaming" them, I realize that copying "in place" won't thrash the disk. I don't mind proceeding with that workaround, but If something breaks halfway, I'm a bit worried that I will have to start all over, downloading ~250GB of TAR files from Google and extracting them.

TheLastGimbus commented 7 months ago

Thanks for you broad case-study :eyes:

I think I would prefer to leave the Google Takeout directory in-place

You can do this! Just use cmd options and --copy

I will have to start all over, downloading ~250GB

Yeah that error could get messy, but just don't delete the original zips...

huh, but you may not have storage not to delete them.... hmm... well, in that case, coping them would trash as much storage as keeping the original zip so that's a tie :+1:

TheLastGimbus commented 7 months ago

https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/commit/6ddd94ac0af5ad032d7b317c624b1fa979ecdc87

:tada: