OSDN Git Service

set permission to 0711 and only after successfully mkdir donut-x86 android-x86-1.6
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 15 Sep 2009 05:42:55 +0000 (13:42 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 15 Sep 2009 05:42:55 +0000 (13:42 +0800)
src/com/android/providers/downloads/Helpers.java

index a02fdc3..f9bfb13 100644 (file)
@@ -181,22 +181,21 @@ public class Helpers {
             if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                 String root = Environment.getExternalStorageDirectory().getPath();
                 base = new File(root + Constants.DEFAULT_DL_SUBDIR);
-                if (!base.isDirectory() && !base.mkdir()) {                    
-                    if (Config.LOGD) {
-                        Log.d(Constants.TAG, "download aborted - can't create base directory "
-                                + base.getPath());
+                if (!base.isDirectory()) {
+                    if (base.mkdir()) {
+                        /*
+                         * Make sure the download directory is accessible
+                         */
+                        FileUtils.setPermissions(base.getPath(),
+                                FileUtils.S_IRWXU|FileUtils.S_IXGRP|FileUtils.S_IXOTH, -1, -1);
+                    } else {
+                        if (Config.LOGD) {
+                            Log.d(Constants.TAG, "download aborted - can't create base directory "
+                                    + base.getPath());
+                        }
+                        return new DownloadFileInfo(null, null, Downloads.STATUS_FILE_ERROR);
                     }
-                    return new DownloadFileInfo(null, null, Downloads.STATUS_FILE_ERROR);
-                }
-                if (base.getName().equalsIgnoreCase("download")) {
-                       /*
-                        * Make sure the download 
-                        */
-                       int re = FileUtils.setPermissions(base.getPath(), 
-                                       FileUtils.S_IRWXU|FileUtils.S_IRGRP|FileUtils.S_IXGRP|FileUtils.S_IROTH|FileUtils.S_IXOTH,
-                                       -1, -1);
                 }
-                       
                 stat = new StatFs(base.getPath());
             } else {
                 if (Config.LOGD) {