Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
FlashSync - Commitdiff - ViewGit - Blue Static

Fix a bug that would cause _writeBindFile() to error out during sync

Robert Sesek [2009-04-14 15:42]
Fix a bug that would cause _writeBindFile() to error out during sync

* lib/FlashSync/DeviceManager.py:
(erase): Now computes the new mount point and returns it after erase
* lib/FlashSync/Monitor.py:
(sync): Use the mount point returned by DeviceManager.erase() rather than computing it itself
diff --git a/lib/FlashSync/DeviceManager.py b/lib/FlashSync/DeviceManager.py
index f9358a6..e2d7e68 100644
--- a/lib/FlashSync/DeviceManager.py
+++ b/lib/FlashSync/DeviceManager.py
@@ -64,12 +64,20 @@ def unbind(volume):
 	logging.debug("Unbound " + volume)

 def erase(volume):
-	"""Erases a given volume"""
+	"""Erases a given volume and returns its new mount point"""
 	logging.debug("Erasing " + volume)

-	devuuid = _getUUID(volume)
-	os.system("diskutil eraseVolume MS-DOS 'PCSC' '" + volume + "' >> " + FlashSync.ROOT + "/db/log 2>&1")
-	_writeBindFile(devuuid, volume)
+	info	= info(volume)
+	devuuid	= _getUUID(volume)
+
+	os.system("diskutil eraseDisk 'MS-DOS' 'PCSC' '" + info["DeviceIdentifier"] + "' >> " + FlashSync.ROOT + "/db/log 2>&1")
+
+	newInfo	= info(info["DeviceIdentifier"])
+	disk	= newInfo["MountPoint"]
+
+	_writeBindFile(devuuid, disk)
+
+	return disk

 def synchronize(volume):
 	"""Copies the db/manifest to a given volume path"""
diff --git a/lib/FlashSync/Monitor.py b/lib/FlashSync/Monitor.py
index c9ff93b..613c52c 100644
--- a/lib/FlashSync/Monitor.py
+++ b/lib/FlashSync/Monitor.py
@@ -80,14 +80,10 @@ def sync():
 	for disk in os.listdir(FlashSync.watchPath):
 		disk = os.path.join(FlashSync.watchPath, disk)
 		uuid = DeviceManager.isBound(disk)
-		info = DeviceManager.info(disk)
 		if uuid:
 			logging.info("Starting sync on " + disk + " (" + uuid + ")")
-			DeviceManager.erase(disk)
+			disk = DeviceManager.erase(disk)
 			logging.info("... erased")
-
-			newInfo = DeviceManager.info(info["DeviceIdentifier"])
-			disk = newInfo["MountPoint"]
 			logging.info("... new mount point at " + disk)

 			DeviceManager.synchronize(disk)