Advertisement
davidjmemmett

zf-11883.patch

Nov 11th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.58 KB | None | 0 0
  1. Index: tests/Zend/Cloud/StorageService/Adapter/FileSystemTest.php
  2. ===================================================================
  3. --- tests/Zend/Cloud/StorageService/Adapter/FileSystemTest.php  (revision 24554)
  4. +++ tests/Zend/Cloud/StorageService/Adapter/FileSystemTest.php  (working copy)
  5. @@ -130,7 +130,7 @@
  6.          } else {
  7.              foreach (scandir($path) as $item) {
  8.                  if (!($item == '.' || $item == '..')) {
  9. -                    $this->_rmRecursive($item);
  10. +                    $this->_rmRecursive($path. '/'. $item);
  11.                  }
  12.              }
  13.              return rmdir($path);
  14. Index: tests/Zend/Cloud/StorageService/TestCase.php
  15. ===================================================================
  16. --- tests/Zend/Cloud/StorageService/TestCase.php    (revision 24554)
  17. +++ tests/Zend/Cloud/StorageService/TestCase.php    (working copy)
  18. @@ -179,7 +179,7 @@
  19.          }
  20.      }
  21.  
  22. -   /**
  23. +    /**
  24.       * Test store item
  25.       *
  26.       * @return void
  27. @@ -207,6 +207,33 @@
  28.      }
  29.  
  30.      /**
  31. +     * Test store item with a slash in the pathname
  32. +     *
  33. +     * @return void
  34. +     */
  35. +    public function testStoreItemStreamWithSlashedPath()
  36. +    {
  37. +        $dummyNameStream = $this->_dummyNamePrefix . 'ForStore/Stream';
  38. +        try {
  39. +            // Test stream data
  40. +            $originalFilename = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/data/dummy_data.txt');
  41. +            $stream = fopen($originalFilename, 'r');
  42. +            $this->_commonStorage->storeItem($dummyNameStream, $stream);
  43. +            $this->_wait();
  44. +
  45. +            $returnedData = $this->_commonStorage->fetchItem($dummyNameStream);
  46. +            $this->assertEquals(file_get_contents($originalFilename), $returnedData);
  47. +            $this->_commonStorage->deleteItem($dummyNameStream);
  48. +        } catch (Exception $e) {
  49. +            try {
  50. +                $this->_commonStorage->deleteItem($dummyNameStream);
  51. +            } catch (Zend_Cloud_Exception $ignoreMe) {
  52. +            }
  53. +            throw $e;
  54. +        }
  55. +    }
  56. +
  57. +    /**
  58.       * Test delete item
  59.       *
  60.       * @return void
  61. Index: library/Zend/Cloud/StorageService/Adapter/FileSystem.php
  62. ===================================================================
  63. --- library/Zend/Cloud/StorageService/Adapter/FileSystem.php    (revision 24554)
  64. +++ library/Zend/Cloud/StorageService/Adapter/FileSystem.php    (working copy)
  65. @@ -36,6 +36,7 @@
  66.       * Options array keys for the file system adapter.
  67.       */
  68.      const LOCAL_DIRECTORY = 'local_directory';
  69. +    const DIR_MODE = 'dir_mode';
  70.  
  71.      /**
  72.       * The directory for the data
  73. @@ -44,6 +45,12 @@
  74.      protected $_directory = null;
  75.  
  76.      /**
  77. +     * The default mode used when creating dirs
  78. +     * @var int
  79. +     */
  80. +    protected $_dir_mode = 0755;
  81. +
  82. +    /**
  83.       * Constructor
  84.       *
  85.       * @param  array|Zend_Config $options
  86. @@ -64,6 +71,10 @@
  87.          } else {
  88.              $this->_directory = realpath(sys_get_temp_dir());
  89.          }
  90. +
  91. +        if (isset($options[self::DIR_MODE])) {
  92. +            $this->_directory = $options[self::DIR_MODE];
  93. +        }
  94.      }
  95.  
  96.      /**
  97. @@ -103,8 +114,12 @@
  98.      public function storeItem($destinationPath, $data, $options = array())
  99.      {
  100.          $path = $this->_getFullPath($destinationPath);
  101. +        $realpath = dirname($path);
  102. +        if (!file_exists($realpath) && !is_dir($realpath)) {
  103. +            mkdir($realpath, $this->_dir_mode, true);
  104. +        }
  105.          file_put_contents($path, $data);
  106. -        chmod($path, 0777);
  107. +        chmod($path, $this->_dir_mode);
  108.      }
  109.  
  110.      /**
  111.  
  112.  
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement