? .cache
? .git
? .project
? .settings
? junk
? logs
? includes/junk
? modules/system/image.actions.inc
? modules/system/system.admin_image.inc
? sites/all/modules/cvs_deploy
? sites/all/modules/devel
? sites/all/modules/drush
? sites/all/modules/imageapi
? sites/default/files
? sites/default/settings.php
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.159
diff -u -p -r1.159 file.inc
--- includes/file.inc	18 Feb 2009 15:19:54 -0000	1.159
+++ includes/file.inc	19 Feb 2009 18:00:27 -0000
@@ -264,7 +264,7 @@ function file_check_location($source, $d
  * @param $fids
  *   An array of file IDs.
  * @param $conditions
- *   An array of conditions to match against the {files} table. These
+ *   An array of conditions to match against the {file} table. These
  *   should be supplied in the form array('field_name' => 'field_value').
  * @return
  *  An array of file objects, indexed by fid.
@@ -273,7 +273,7 @@ function file_check_location($source, $d
  * @see file_load()
  */
 function file_load_multiple($fids = array(), $conditions = array()) {
-  $query = db_select('files', 'f')->fields('f');
+  $query = db_select('file', 'f')->fields('f');
 
   // If the $fids array is populated, add those to the query.
   if ($fids) {
@@ -335,12 +335,12 @@ function file_save($file) {
   $file->filesize = filesize($file->filepath);
 
   if (empty($file->fid)) {
-    drupal_write_record('files', $file);
+    drupal_write_record('file', $file);
     // Inform modules about the newly added file.
     module_invoke_all('file_insert', $file);
   }
   else {
-    drupal_write_record('files', $file, 'fid');
+    drupal_write_record('file', $file, 'fid');
     // Inform modules that the file has been updated.
     module_invoke_all('file_update', $file);
   }
@@ -762,7 +762,7 @@ function file_delete($file, $force = FAL
   // Make sure the file is deleted before removing its row from the
   // database, so UIs can still find the file in the database.
   if (file_unmanaged_delete($file->filepath)) {
-    db_delete('files')->condition('fid', $file->fid)->execute();
+    db_delete('file')->condition('fid', $file->fid)->execute();
     return TRUE;
   }
   return FALSE;
@@ -852,7 +852,7 @@ function file_unmanaged_delete_recursive
  *   An integer containing the number of bytes used.
  */
 function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
-  $query = db_select('files', 'f');
+  $query = db_select('file', 'f');
   // Use separate placeholders for the status to avoid a bug in some versions
   // of PHP. @see http://drupal.org/node/352956
   $query->where('f.status & :status1 = :status2', array(':status1' => $status, ':status2' => $status));
Index: modules/simpletest/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file.test,v
retrieving revision 1.24
diff -u -p -r1.24 file.test
--- modules/simpletest/tests/file.test	18 Feb 2009 15:07:27 -0000	1.24
+++ modules/simpletest/tests/file.test	19 Feb 2009 18:00:27 -0000
@@ -167,7 +167,7 @@ class FileTestCase extends DrupalWebTest
     $file->status = 0;
     // Write the record directly rather than calling file_save() so we don't
     // invoke the hooks.
-    $this->assertNotIdentical(drupal_write_record('files', $file), FALSE, t('The file was added to the database.'), 'Create test file');
+    $this->assertNotIdentical(drupal_write_record('file', $file), FALSE, t('The file was added to the database.'), 'Create test file');
 
     return $file;
   }
@@ -261,16 +261,16 @@ class FileSpaceUsedTest extends FileTest
     parent::setUp();
 
     // Create records for a couple of users with different sizes.
-    drupal_write_record('files', $file = array('uid' => 2, 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT));
-    drupal_write_record('files', $file = array('uid' => 2, 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT));
-    drupal_write_record('files', $file = array('uid' => 3, 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT));
-    drupal_write_record('files', $file = array('uid' => 3, 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT));
+    drupal_write_record('file', $file = array('uid' => 2, 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT));
+    drupal_write_record('file', $file = array('uid' => 2, 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT));
+    drupal_write_record('file', $file = array('uid' => 3, 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT));
+    drupal_write_record('file', $file = array('uid' => 3, 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT));
 
     // Now create some with other statuses. These values were chosen arbitrarily
     // for the sole purpose of testing that bitwise operators were used
     // correctly on the field.
-    drupal_write_record('files', $file = array('uid' => 2, 'filesize' => 1, 'status' => 2 | 8));
-    drupal_write_record('files', $file = array('uid' => 3, 'filesize' => 3, 'status' => 2 | 4));
+    drupal_write_record('file', $file = array('uid' => 2, 'filesize' => 1, 'status' => 2 | 8));
+    drupal_write_record('file', $file = array('uid' => 3, 'filesize' => 3, 'status' => 2 | 4));
   }
 
   /**
@@ -527,7 +527,7 @@ class FileSaveUploadTest extends FileHoo
     $this->image = current($this->drupalGetTestFiles('image'));
     $this->assertTrue(is_file($this->image->filename), t("The file we're going to upload exists."));
 
-    $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
+    $this->maxFidBefore = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField();
 
     // Upload with replace to gurantee there's something there.
     $edit = array(
@@ -548,7 +548,7 @@ class FileSaveUploadTest extends FileHoo
    * Test the file_save_upload() function.
    */
   function testNormal() {
-    $max_fid_after = db_result(db_query('SELECT MAX(fid) AS fid FROM {files}'));
+    $max_fid_after = db_result(db_query('SELECT MAX(fid) AS fid FROM {file}'));
     $this->assertTrue($max_fid_after > $this->maxFidBefore, t('A new file was created.'));
     $file1 = file_load($max_fid_after);
     $this->assertTrue($file1, t('Loaded the file.'));
@@ -557,13 +557,13 @@ class FileSaveUploadTest extends FileHoo
     file_test_reset();
 
     // Upload a second file.
-    $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
+    $max_fid_before = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField();
     $image2 = current($this->drupalGetTestFiles('image'));
     $edit = array('files[file_test_upload]' => realpath($image2->filename));
     $this->drupalPost('file-test/upload', $edit, t('Submit'));
     $this->assertResponse(200, t('Received a 200 response for posted test file.'));
     $this->assertRaw(t('You WIN!'));
-    $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
+    $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {file}')->fetchField();
 
     // Check that the correct hooks were called.
     $this->assertFileHooksCalled(array('validate', 'insert'));
@@ -1677,7 +1677,7 @@ class FileSaveTest extends FileHookTestC
 
     $this->assertNotNull($saved_file, t("Saving the file should give us back a file object."), 'File');
     $this->assertTrue($saved_file->fid > 0, t("A new file ID is set when saving a new file to the database."), 'File');
-    $loaded_file = db_query('SELECT * FROM {files} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ);
+    $loaded_file = db_query('SELECT * FROM {file} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ);
     $this->assertNotNull($loaded_file, t("Record exists in the database."));
     $this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly."));
     $this->assertEqual($saved_file->filesize, filesize($file->filepath), t("File size was set correctly."), 'File');
@@ -1694,7 +1694,7 @@ class FileSaveTest extends FileHookTestC
 
     $this->assertEqual($resaved_file->fid, $saved_file->fid, t("The file ID of an existing file is not changed when updating the database."), 'File');
     $this->assertTrue($resaved_file->timestamp >= $saved_file->timestamp, t("Timestamp didn't go backwards."), 'File');
-    $loaded_file = db_query('SELECT * FROM {files} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ);
+    $loaded_file = db_query('SELECT * FROM {file} f WHERE f.fid = :fid', array(':fid' => $saved_file->fid))->fetch(PDO::FETCH_OBJ);
     $this->assertNotNull($loaded_file, t("Record still exists in the database."), 'File');
     $this->assertEqual($loaded_file->status, $saved_file->status, t("Status was saved correctly."));
   }
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.19
diff -u -p -r1.19 system.api.php
--- modules/system/system.api.php	18 Feb 2009 15:19:56 -0000	1.19
+++ modules/system/system.api.php	19 Feb 2009 18:00:27 -0000
@@ -1231,7 +1231,7 @@ function hook_file_status($file) {
 function hook_file_download($filepath) {
   // Check if the file is controlled by the current module.
   $filepath = file_create_path($filepath);
-  $result = db_query("SELECT f.* FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = '%s'", $filepath);
+  $result = db_query("SELECT f.* FROM {file} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = '%s'", $filepath);
   if ($file = db_fetch_object($result)) {
     if (!user_access('view uploaded files')) {
       return -1;
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.308
diff -u -p -r1.308 system.install
--- modules/system/system.install	18 Feb 2009 15:19:56 -0000	1.308
+++ modules/system/system.install	19 Feb 2009 18:00:27 -0000
@@ -598,7 +598,7 @@ function system_schema() {
   $schema['cache_registry'] = $schema['cache'];
   $schema['cache_registry']['description'] = 'Cache table for the code registry system to remember what code files need to be loaded on any given page.';
 
-  $schema['files'] = array(
+  $schema['file'] = array(
     'description' => 'Stores information for uploaded files.',
     'fields' => array(
       'fid' => array(
@@ -661,6 +661,9 @@ function system_schema() {
       'status' => array('status'),
       'timestamp' => array('timestamp'),
     ),
+    'unique keys' => array(
+      'filepath' => array('filepath'),
+    ),
     'primary key' => array('fid'),
   );
 
@@ -3226,6 +3229,85 @@ function system_update_7019() {
 }
 
 /**
+ * Create the {file} with the unique key on the filepath.
+ */
+function system_update_7020() {
+  $ret = array();
+
+  $schema['file'] = array(
+    'description' => 'Stores information for uploaded files.',
+    'fields' => array(
+      'fid' => array(
+        'description' => 'File ID.',
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+      ),
+      'uid' => array(
+        'description' => 'The {user}.uid of the user who is associated with the file.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'filename' => array(
+        'description' => 'Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'filepath' => array(
+        'description' => 'Path of the file relative to Drupal root.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'filemime' => array(
+        'description' => "The file's MIME type.",
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'filesize' => array(
+        'description' => 'The size of the file in bytes.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'status' => array(
+        'description' => 'A bitmapped field indicating the status of the file the least sigifigant bit indicates temporary (1) or permanent (0). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'timestamp' => array(
+        'description' => 'UNIX timestamp for when the file was added.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+    ),
+    'indexes' => array(
+      'uid' => array('uid'),
+      'status' => array('status'),
+      'timestamp' => array('timestamp'),
+    ),
+    'unique keys' => array(
+      'filepath' => array('filepath'),
+    ),
+    'primary key' => array('fid'),
+  );
+  db_create_table($ret, 'file', $schema['file']);
+
+  return $ret;
+}
+
+/**
  * @} End of "defgroup updates-6.x-to-7.x"
  * The next series of updates should start at 8000.
  */
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.667
diff -u -p -r1.667 system.module
--- modules/system/system.module	11 Feb 2009 05:33:18 -0000	1.667
+++ modules/system/system.module	19 Feb 2009 18:00:27 -0000
@@ -1555,7 +1555,7 @@ function system_cron() {
   // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
   // Use separate placeholders for the status to avoid a bug in some versions
   // of PHP. @see http://drupal.org/node/352956
-  $result = db_query('SELECT fid FROM {files} WHERE status & :permanent1 != :permanent2 AND timestamp < :timestamp', array(':permanent1' => FILE_STATUS_PERMANENT, ':permanent2' => FILE_STATUS_PERMANENT, ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE));
+  $result = db_query('SELECT fid FROM {file} WHERE status & :permanent1 != :permanent2 AND timestamp < :timestamp', array(':permanent1' => FILE_STATUS_PERMANENT, ':permanent2' => FILE_STATUS_PERMANENT, ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE));
   foreach ($result as $row) {
     if ($file = file_load($row->fid)) {
       if (!file_delete($file)) {
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.39
diff -u -p -r1.39 system.test
--- modules/system/system.test	11 Feb 2009 05:33:18 -0000	1.39
+++ modules/system/system.test	19 Feb 2009 18:00:27 -0000
@@ -295,17 +295,17 @@ class CronRunTestCase extends DrupalWebT
 
     // Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
     $temp_old = file_save_data('');
-    db_query('UPDATE {files} SET status = :status, timestamp = :timestamp WHERE fid = :fid', array(':status' => 0, ':timestamp' => 1, ':fid' => $temp_old->fid));
+    db_query('UPDATE {file} SET status = :status, timestamp = :timestamp WHERE fid = :fid', array(':status' => 0, ':timestamp' => 1, ':fid' => $temp_old->fid));
     $this->assertTrue(file_exists($temp_old->filepath), t('Old temp file was created correctly.'));
 
     // Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
     $temp_new = file_save_data('');
-    db_query('UPDATE {files} SET status = :status WHERE fid = :fid', array(':status' => 0, ':fid' => $temp_new->fid));
+    db_query('UPDATE {file} SET status = :status WHERE fid = :fid', array(':status' => 0, ':fid' => $temp_new->fid));
     $this->assertTrue(file_exists($temp_new->filepath), t('New temp file was created correctly.'));
 
     // Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
     $perm_old = file_save_data('');
-    db_query('UPDATE {files} SET timestamp = :timestamp WHERE fid = :fid', array(':timestamp' => 1, ':fid' => $perm_old->fid));
+    db_query('UPDATE {file} SET timestamp = :timestamp WHERE fid = :fid', array(':timestamp' => 1, ':fid' => $perm_old->fid));
     $this->assertTrue(file_exists($perm_old->filepath), t('Old permanent file was created correctly.'));
 
     // Permanent file that is newer than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
@@ -878,7 +878,7 @@ class SystemThemeFunctionalTest extends 
       'node_admin_theme' => FALSE,
     );
     $this->drupalPost('admin/build/themes', $edit, t('Save configuration'));
-    
+
     $this->drupalGet('admin');
     $this->assertRaw('themes/garland', t('Administration theme used on an administration page.'));
 
@@ -887,7 +887,7 @@ class SystemThemeFunctionalTest extends 
 
     // Reset to the default theme settings.
     $this->drupalPost('admin/build/themes', array(), t('Reset to defaults'));
-    
+
     $this->drupalGet('admin');
     $this->assertRaw('themes/garland', t('Site default theme used on administration page.'));
 
Index: modules/upload/upload.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.install,v
retrieving revision 1.8
diff -u -p -r1.8 upload.install
--- modules/upload/upload.install	15 Nov 2008 13:01:11 -0000	1.8
+++ modules/upload/upload.install	19 Feb 2009 18:00:27 -0000
@@ -33,7 +33,7 @@ function upload_schema() {
         'unsigned' => TRUE,
         'not null' => TRUE,
         'default' => 0,
-        'description' => 'Primary Key: The {files}.fid.',
+        'description' => 'Primary Key: The {file}.fid.',
       ),
       'nid' => array(
         'type' => 'int',
@@ -83,3 +83,53 @@ function upload_schema() {
 }
 
 
+/**
+ * Migrate upload module files from {files} to {file}.
+ */
+function upload_update_7000(&$sandbox) {
+  $ret = array();
+
+  if (!isset($sandbox['progress'])) {
+    // Initialize batch update information.
+    $sandbox['progress'] = 0;
+    $sandbox['last_fid_processed'] = -1;
+    $sandbox['max'] = db_query("SELECT COUNT(DISTINCT u.fid) FROM {upload} u")->fetchField();
+  }
+
+  // As a batch operation move records from {files} into the {file} table.
+  $limit = 500;
+  $result = db_query_range("SELECT DISTINCT u.fid FROM {upload} u ORDER BY u.vid", array(), 0, $limit);
+  foreach ($result as $record) {
+    $old_file = db_query('SELECT f.* FROM {files} f WHERE f.fid = :fid', array(':fid' => $record->fid))->fetch(PDO::FETCH_OBJ);
+    if (!$old_file) {
+      continue;
+    }
+
+    $new_file = db_query('SELECT f.* FROM {files} f WHERE f.filepath = :filepath', array(':filepath' => $old_file->filepath))->fetch(PDO::FETCH_OBJ);
+    if (!$new_file) {
+      // Re-save the file into the new {file} table.
+      $new_file = clone $old_file;
+      drupal_write_record('file', $new_file);
+    }
+
+    // If the fid has changed we need to update the {upload} record to use the
+    // new id.
+    if (!empty($new_file->fid) && ($new_file->fid != $old_file->fid)) {
+      db_update('upload')
+        ->fields(array('fid' => $new_file->fid))
+        ->condition('fid', $old_file->fid)
+        ->execute();
+    }
+
+    // Update our progress information for the batch update.
+    $sandbox['progress']++;
+    $sandbox['last_fid_processed'] = $old_file->fid;
+  }
+
+  // Indicate our current progress to the batch update system. If there's no
+  // max value then there's nothing to update and we're finished.
+  $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
+
+  return $ret;
+}
+
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.227
diff -u -p -r1.227 upload.module
--- modules/upload/upload.module	3 Feb 2009 18:55:32 -0000	1.227
+++ modules/upload/upload.module	19 Feb 2009 18:00:27 -0000
@@ -152,7 +152,7 @@ function _upload_file_limits($user) {
  */
 function upload_file_download($filepath) {
   $filepath = file_create_path($filepath);
-  $file = db_query("SELECT f.*, u.nid FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = :path", array(':path' => $filepath))->fetchObject();
+  $file = db_query("SELECT f.*, u.nid FROM {file} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = :path", array(':path' => $filepath))->fetchObject();
 
   if ($file && user_access('view uploaded files') && ($node = node_load($file->nid)) && node_access('view', $node)) {
     return array(
@@ -477,7 +477,7 @@ function upload_space_used($uid) {
  *   The amount of disk space used by uploaded files in bytes.
  */
 function upload_total_space_used() {
-  return db_query('SELECT SUM(f.filesize) FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid')->fetchField();
+  return db_query('SELECT SUM(f.filesize) FROM {file} f INNER JOIN {upload} u ON f.fid = u.fid')->fetchField();
 }
 
 function upload_save(&$node) {
Index: modules/user/user.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.install,v
retrieving revision 1.18
diff -u -p -r1.18 user.install
--- modules/user/user.install	18 Feb 2009 15:19:57 -0000	1.18
+++ modules/user/user.install	19 Feb 2009 18:00:27 -0000
@@ -173,7 +173,7 @@ function user_schema() {
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0,
-        'description' => "Foreign key: {files}.fid of user's picture.",
+        'description' => "Foreign key: {file}.fid of user's picture.",
       ),
       'init' => array(
         'type' => 'varchar',
@@ -387,7 +387,7 @@ function user_update_7003() {
 }
 
 /**
- * Add the user's pictures to the {files} table and make them managed files.
+ * Add the user's pictures to the {file} table and make them managed files.
  */
 function user_update_7004(&$sandbox) {
   $ret = array();
@@ -396,7 +396,7 @@ function user_update_7004(&$sandbox) {
     'type' => 'int',
     'not null' => TRUE,
     'default' => 0,
-    'description' => t("Foriegn key: {files}.fid of user's picture."),
+    'description' => t("Foriegn key: {file}.fid of user's picture."),
   );
 
   if (!isset($sandbox['progress'])) {
@@ -413,7 +413,7 @@ function user_update_7004(&$sandbox) {
     $sandbox['max'] = db_query("SELECT COUNT(*) FROM {user} WHERE picture <> ''")->fetchField();
   }
 
-  // As a batch operation move the photos into the {files} table and update the
+  // As a batch operation move the photos into the {file} table and update the
   // {user} records.
   $limit = 500;
   $result = db_query_range("SELECT uid, picture FROM {user} WHERE picture <> '' AND uid > :uid ORDER BY uid", array(':uid' => $sandbox['last_user_processed']), 0, $limit);
