File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed
Controller/Adminhtml/Sitemap
Test/Unit/Controller/Adminhtml/Sitemap Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -172,14 +172,25 @@ public function move($fileName, $renameFileOff = false)
172
172
$ read = $ this ->_readFactory ->create ($ url , DriverPool::HTTPS );
173
173
}
174
174
175
+ if ($ this ->getTmpDir ()) {
176
+ $ filePath = $ this ->getTmpDir () . '/ ' ;
177
+ } else {
178
+ $ filePath = '' ;
179
+ }
175
180
$ fileName = preg_replace ('/[^a-z0-9\._-]+/i ' , '' , $ fileName );
181
+ $ filePath = $ this ->_directory ->getRelativePath ($ filePath . $ fileName );
176
182
$ this ->_directory ->writeFile (
177
- $ this -> _directory -> getRelativePath ( $ this -> getTmpDir () . ' / ' . $ fileName ) ,
183
+ $ filePath ,
178
184
$ read ->readAll ()
179
185
);
180
186
}
181
187
182
- $ filePath = $ this ->_directory ->getRelativePath ($ this ->getTmpDir () . '/ ' . $ fileName );
188
+ if ($ this ->getTmpDir ()) {
189
+ $ filePath = $ this ->getTmpDir () . '/ ' ;
190
+ } else {
191
+ $ filePath = '' ;
192
+ }
193
+ $ filePath = $ this ->_directory ->getRelativePath ($ filePath . $ fileName );
183
194
$ this ->_setUploadFile ($ filePath );
184
195
$ destDir = $ this ->_directory ->getAbsolutePath ($ this ->getDestDir ());
185
196
$ result = $ this ->save ($ destDir );
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ protected function setUp()
119
119
public function testMoveFileUrl ($ fileUrl , $ expectedHost , $ expectedFileName )
120
120
{
121
121
$ destDir = 'var/dest/dir ' ;
122
- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ expectedFileName ;
122
+ $ expectedRelativeFilePath = $ expectedFileName ;
123
123
$ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
124
124
$ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
125
125
$ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
@@ -155,7 +155,7 @@ public function testMoveFileName()
155
155
{
156
156
$ destDir = 'var/dest/dir ' ;
157
157
$ fileName = 'test_uploader_file ' ;
158
- $ expectedRelativeFilePath = $ this -> uploader -> getTmpDir () . ' / ' . $ fileName ;
158
+ $ expectedRelativeFilePath = $ fileName ;
159
159
$ this ->directoryMock ->expects ($ this ->once ())->method ('isWritable ' )->with ($ destDir )->willReturn (true );
160
160
$ this ->directoryMock ->expects ($ this ->any ())->method ('getRelativePath ' )->with ($ expectedRelativeFilePath );
161
161
$ this ->directoryMock ->expects ($ this ->once ())->method ('getAbsolutePath ' )->with ($ destDir )
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ public function execute()
53
53
$ sitemap ->load ($ id );
54
54
// delete file
55
55
$ sitemapPath = $ sitemap ->getSitemapPath ();
56
+ if ($ sitemapPath && $ sitemapPath [0 ] === DIRECTORY_SEPARATOR ) {
57
+ $ sitemapPath = mb_substr ($ sitemapPath , 1 );
58
+ }
56
59
$ sitemapFilename = $ sitemap ->getSitemapFilename ();
57
60
58
61
$ path = $ directory ->getRelativePath ($ sitemapPath . $ sitemapFilename );
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ public function testExecute()
135
135
$ this ->sitemapFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ sitemapMock );
136
136
$ writeDirectoryMock ->expects ($ this ->any ())
137
137
->method ('getRelativePath ' )
138
- ->with ($ sitemapPath . $ sitemapFilename )
138
+ ->with ($ sitemapFilename )
139
139
->willReturn ($ relativePath );
140
140
$ writeDirectoryMock ->expects ($ this ->once ())->method ('isFile ' )->with ($ relativePath )->willReturn (true );
141
141
$ writeDirectoryMock ->expects ($ this ->once ())->method ('delete ' )->with ($ relativePath )->willReturn (true );
You can’t perform that action at this time.
0 commit comments