LibraryOfCongress / bagit-python

Work with BagIt packages from Python.
http://libraryofcongress.github.io/bagit-python
216 stars 85 forks source link

Extra TEMP Directory Created & Preserved #134

Closed gnosisgithub closed 4 years ago

gnosisgithub commented 5 years ago

BagIt-Version: 0.97

When I run bagit it always creates a tertiary directory:

For example: C:\Users\smith\Desktop\desktop\bagit-python-master>bagit.py --contact-name 'Stephen' C:\Users\smith\Desktop\project\Appendices

===> C:\Users\smith\Desktop\project\Appendices becomes: C:\Users\sklein\Desktop\project\data\tmpvi4hndq5\Appendices\

Is this a bug? Will it effect checksum reporting? If so, how to prevent the creation of this random directory (in this example:\tmpvi4hndq5)

Also, the first time I run bagit: 'C:\Users\smith\Desktop\desktop\bagit-python-master>bagit.py --contact-name 'Stephen' C:\Users\smith\Desktop\project\Appendices' always fails, so I always have to run the command a second time in the same command prompt.

I assume the bagging command has finished processing: C:\Users\sklein\Desktop\desktop\bagger-master>bagit.py --contact-name 'Stephen' C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\ 2019-04-17 08:39:00,309 - INFO - Creating bag for directory C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\ 2019-04-17 08:39:00,310 - INFO - Creating data directory 2019-04-17 08:39:00,312 - INFO - Moving bagger-2.8.1.zip to C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tmpj0oqfy7h\bagger-2.8.1.zip 2019-04-17 08:39:00,314 - INFO - Moving bagger-master.zip to C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tmpj0oqfy7h\bagger-master.zip 2019-04-17 08:39:00,316 - INFO - Moving exactly_0.1.5_64bit.zip to C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tmpj0oqfy7h\exactly_0.1.5_64bit.zip 2019-04-17 08:39:00,318 - INFO - Moving Fixity-1.2-Win.zip to C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tmpj0oqfy7h\Fixity-1.2-Win.zip 2019-04-17 08:39:00,320 - INFO - Moving C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tmpj0oqfy7h to data 2019-04-17 08:39:00,323 - INFO - Using 1 processes to generate manifests: sha256, sha512 2019-04-17 08:39:00,323 - INFO - Generating manifest lines for file data/Fixity-1.2-Win.zip 2019-04-17 08:39:00,847 - INFO - Generating manifest lines for file data/bagger-2.8.1.zip 2019-04-17 08:39:02,046 - INFO - Generating manifest lines for file data/bagger-master.zip 2019-04-17 08:39:02,237 - INFO - Generating manifest lines for file data/exactly_0.1.5_64bit.zip 2019-04-17 08:39:03,390 - INFO - Creating bagit.txt 2019-04-17 08:39:03,398 - INFO - Creating bag-info.txt 2019-04-17 08:39:03,403 - INFO - Creating C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tagmanifest-sha256.txt 2019-04-17 08:39:03,411 - INFO - Creating C:\Users\sklein\Desktop\downloads\firefox\dig_pres_tools\tagmanifest-sha512.txt

And unpredictable, because sometime the temp directory is not removed and sometimes it is.

acdha commented 5 years ago

I'm curious why “the first time I run bagit … always fails” is true. Bagit does its work in a temporary directory which is normally renamed at the end of the process; cleaning up is a problem if it requires dealing with the files which are stored in that directory.

Do you have an error log from one of the failing runs? I'm wondering whether it's something like Windows not allowing an open file/directory to be deleted or renamed.

gnosisgithub commented 5 years ago

Thanks, Chris. Where would the log be saved to? Or how to generate?

gnosisgithub commented 5 years ago

When I run: C:\Users\sklein\Desktop\desktop\bagger-master>bagit.py --contact-name 'Stephen' C:\Users\sklein\Desktop\jm_pilot\

This is returned: 2019-04-17 14:42:29,980 - INFO - Creating bag for directory C:\Users\sklein\Desktop\jm_pilot\ 2019-04-17 14:42:30,005 - INFO - Creating data directory 2019-04-17 14:42:30,007 - INFO - Moving data to C:\Users\sklein\Desktop\jm_pilot\tmp0mtmbr3n\data 2019-04-17 14:42:30,008 - ERROR - An error occurred creating a bag in C:\Users\sklein\Desktop\jm_pilot\ Traceback (most recent call last): File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 224, in make_bag os.rename(f, new_f) PermissionError: [WinError 5] Access is denied: 'data' -> 'C:\Users\sklein\Desktop\jm_pilot\tmp0mtmbr3n\data' 2019-04-17 14:42:30,026 - ERROR - Failed to create bag in C:\Users\sklein\Desktop\jm_pilot\: [WinError 5] Access is denied: 'data' -> 'C:\Users\sklein\Desktop\jm_pilot\tmp0mtmbr3n\data' Traceback (most recent call last): File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 1598, in main checksums=args.checksums, File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 224, in make_bag os.rename(f, new_f) PermissionError: [WinError 5] Access is denied: 'data' -> 'C:\Users\sklein\Desktop\jm_pilot\tmp0mtmbr3n\data'

I run it a second time and it runs successfully, however two new issues: \jm_pilot\data\ becomes: \jm_pilot\data\data\

-and- this directory is created, but this time empty: \jm_pilot\data\tmp0mtmbr3n

Sometimes it creates a temp and then places all data into temp

gnosisgithub commented 5 years ago

another example:

C:\Users\sklein\Desktop\desktop\bagger-master>bagit.py --contact-name 'Stephen' C:\Users\sklein\Desktop\dig_work\jm_finaltesting\ 2019-04-25 14:01:50,218 - INFO - Creating bag for directory C:\Users\sklein\Desktop\dig_work\jm_finaltesting\ 2019-04-25 14:01:50,224 - INFO - Creating data directory 2019-04-25 14:01:50,226 - INFO - Moving .dropbox to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i.dropbox 2019-04-25 14:01:50,228 - INFO - Moving ARIS to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\ARIS 2019-04-25 14:01:50,231 - INFO - Moving jm_final.txt to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\jm_final.txt 2019-04-25 14:01:50,233 - INFO - Moving Merandy - Dissertation White Paper.pdf to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\Merandy - Dissertation White Paper.pdf 2019-04-25 14:01:50,235 - INFO - Moving Readme.pdf to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\Readme.pdf 2019-04-25 14:01:50,237 - INFO - Moving Websites to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\Websites 2019-04-25 14:01:50,722 - INFO - Moving Whitepaper, Appendices and Readme to C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i\Whitepaper, Appendices and Readme 2019-04-25 14:01:50,724 - INFO - Moving C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i to data 2019-04-25 14:01:50,726 - ERROR - An error occurred creating a bag in C:\Users\sklein\Desktop\dig_work\jm_finaltesting\ Traceback (most recent call last): File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 230, in make_bag os.rename(temp_data, "data") PermissionError: [WinError 5] Access is denied: 'C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i' -> 'data' 2019-04-25 14:01:50,728 - ERROR - Failed to create bag in C:\Users\sklein\Desktop\dig_work\jm_finaltesting\: [WinError 5] Access is denied: 'C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i' -> 'data' Traceback (most recent call last): File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 1598, in main checksums=args.checksums, File "C:\Users\sklein\AppData\Local\Programs\Python\Python37-32\Scripts\bagit.py", line 230, in make_bag os.rename(temp_data, "data") PermissionError: [WinError 5] Access is denied: 'C:\Users\sklein\Desktop\dig_work\jm_finaltesting\tmp8lu1f48i' -> 'data'

gnosisgithub commented 4 years ago

All resolved if I turn of all virus scanners. I use the Mcafee RemovalTool.exe.

acdha commented 4 years ago

That would explain it — virus scanners are notorious for breaking things like that since Windows won't allow open files/directories to be renamed and they'll keep newly-created files open for some period of time without the user's knowledge.