[pLog-svn] r4444 - plog/trunk/class/gallery/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Dec 28 21:46:14 GMT 2006


Author: oscar
Date: 2006-12-28 21:46:14 +0000 (Thu, 28 Dec 2006)
New Revision: 4444

Modified:
   plog/trunk/class/gallery/dao/galleryresources.class.php
   plog/trunk/class/gallery/dao/galleryresourcestorage.class.php
Log:
fixed GalleryResources::addResourceFromDisk()


Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php	2006-12-28 19:23:56 UTC (rev 4443)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php	2006-12-28 21:46:14 UTC (rev 4444)
@@ -626,9 +626,6 @@
                 return GALLERY_ERROR_QUOTA_EXCEEDED;
             }
             
-            $fileName = basename( $fullFilePath );
-            $filePath = dirname( $fullFilePath );
-        
             // get the metadata
             lt_include( PLOG_CLASS_PATH."class/gallery/getid3/getid3.php" );            
             $getId3 = new GetID3();
@@ -644,11 +641,24 @@
             if( $resourceType == GALLERY_RESOURCE_IMAGE )
                 $flags = $flags|GALLERY_RESOURCE_PREVIEW_AVAILABLE;
     
-            // add the record to the database            
-            $resourceId = $this->addResourceToDatabase( $ownerId, $albumId, $description, $flags, $resourceType, 
-                                                        $filePath, $fileName, $metadata );
+            // add the record to the database
+            $fileName = basename( $fullFilePath );
+			$duplicated = $this->isDuplicatedFilename( $fileName );
+            $filePath = "";
+        
+			$resourceId = $this->addResourceToDatabase( $ownerId, $albumId, $description, $flags, $resourceType, $filePath, $fileName, $info );
             if( !$resourceId )
                 return false;
+
+			if( $duplicated ) {
+				//
+				// :TODO:
+				// ugly...
+				//
+				$newFilePath = dirname( $fullFilePath)."/".$resourceId."-".basename( $fullFilePath );				
+				File::rename( $fullFilePath, $newFilePath );
+				$fullFilePath = $newFilePath;
+			}
     
             // and finally move the file to the right place in disk
             // move the file to disk

Modified: plog/trunk/class/gallery/dao/galleryresourcestorage.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresourcestorage.class.php	2006-12-28 19:23:56 UTC (rev 4443)
+++ plog/trunk/class/gallery/dao/galleryresourcestorage.class.php	2006-12-28 21:46:14 UTC (rev 4444)
@@ -290,7 +290,8 @@
             // new name for the file
             $fileParts = explode( ".", $fileName);
             $fileExt = $fileParts[count($fileParts)-1];
-            $destFile = "$ownerId-$resourceId.$fileExt";
+            //$destFile = "$ownerId-$resourceId.$fileExt";
+			$destFile = basename( $fileName );
             $destPath = $this->getUserFolder( $ownerId );
 
 			// first of all, check if the file is readable and if not, quit	



More information about the pLog-svn mailing list