-
Notifications
You must be signed in to change notification settings - Fork 2
Description
On occasion when the power is abruptly cut to the RaspberryPi running dencam, USB attached storage drives (microSD cards in card readers) do not appear to be properly ejected. The name of the drive appears to stick in /media/pi.
Several of my Pi's (I am currently testing five with four different batteries) have been neglecting to display the second status page. This, as I have come to find out, is because the system is remembering the names of my attached storage when the pi is not properly shut down (nearly every time I just pull the plug). This is easy enough to solve (just ssh in and cd /media/pi and sudo rmdir X). But in the field, this could be catastrophic as these pseudo-replicated drives prevent dencam.py from writing to either the external or internal storage.
Potential fix:
EDIA_DIR = '/media/pi'
def clearGhostDrives():
"""Delete non-existent USB drives"""
# When power is removed (no shut-down) and a USB drive is removed,
# then the power is restored, a ghost folder is left in /media/pi/
# Distinguishing between ghost folders and real ones has proven to be too much of a challenge
# Instead, this function deletes all the USB folders
# This is executed when powering up, before the USB drive is mounted
# Therefore, after this removes all the folders, the system mounts the USB drive that actually exists
# Locals
DEL_DIR_CMD = 'sudo rm -r %s/%s'
usbDrivesList = os.listdir(MEDIA_DIR)
if len(usbDrivesList) > 1:
for usbDriveName in usbDrivesList:
doLinuxCmd(DEL_DIR_CMD % (MEDIA_DIR, usbDriveName))