Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.112
diff -u -r1.112 file.inc
--- includes/file.inc	26 Nov 2007 16:36:42 -0000	1.112
+++ includes/file.inc	29 Nov 2007 17:50:03 -0000
@@ -959,7 +959,7 @@
  * @return A string containing the path to Drupal's 'files' directory.
  */
 function file_directory_path() {
-  return variable_get('file_directory_path', 'files');
+  return variable_get('file_directory_path', conf_path() .'/files');
 }
 
 /**
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.199
diff -u -r1.199 system.install
--- modules/system/system.install	29 Nov 2007 12:02:06 -0000	1.199
+++ modules/system/system.install	29 Nov 2007 17:50:00 -0000
@@ -2728,6 +2728,24 @@
   return $ret;
 }
 
+ /**
+ * Files directory now defaults to conf_path()/files so explicitly set
+ * file_directory_path to /files if files have aleady been uploaded to that
+ * directory.
+ */
+function system_update_6041() {
+  if (!variable_get('file_directory_path', '') && is_dir('files')) {
+    // File_directory_path has not been set and the files directory exists.
+    $count = db_result(db_query("SELECT COUNT(*) FROM {files} f WHERE f.filepath LIKE 'files/%%'"));
+    if ($count > 0) {
+      // At least one file has been uploaded to the files directory, so we need
+      // to explicitly set the variable now that the default has changed.
+      variable_set('file_directory_path', 'files');
+    }
+  }
+  return array();
+}
+
 /**
  * @} End of "defgroup updates-5.x-to-6.x"
  * The next series of updates should start at 7000.
