@@ -145,6 +145,41 @@ protected function parseSpecificContributions(&$contribNode)
145
145
$ this ->disableArchiveBrowsingContributions ($ contribNode );
146
146
}
147
147
148
+ /**
149
+ * We have to overwrite original FS function as S3 wrapper does not support "a+" open mode.
150
+ *
151
+ * @param String $folder Folder destination
152
+ * @param String $source Maybe updated by the function
153
+ * @param String $target Existing part to append data
154
+ * @return bool If the target file already existed or not.
155
+ * @throws Exception
156
+ */
157
+ protected function appendUploadedData ($ folder , $ source , $ target ){
158
+
159
+ $ already_existed = false ;
160
+ if ($ source == $ target ){
161
+ throw new Exception ("Something nasty happened: trying to copy $ source into itself, it will create a loop! " );
162
+ }
163
+ // S3 does not really support append. Let's grab the remote target first.
164
+ if (file_exists ($ folder ."/ " . $ target )) {
165
+ $ already_existed = true ;
166
+ $ this ->logDebug ("Should copy stream from $ source to $ target - folder is ( $ folder) " );
167
+ $ partO = fopen ($ folder ."/ " .$ source , "r " );
168
+ $ appendF = fopen ($ folder ."/ " . $ target , 'a ' );
169
+ while (!feof ($ partO )) {
170
+ $ buf = fread ($ partO , 1024 );
171
+ fwrite ($ appendF , $ buf );
172
+ }
173
+ fclose ($ partO );
174
+ fclose ($ appendF );
175
+ $ this ->logDebug ("Done, closing streams! " );
176
+ }
177
+ @unlink ($ folder ."/ " .$ source );
178
+ return $ already_existed ;
179
+
180
+ }
181
+
182
+
148
183
public function isWriteable ($ dir , $ type ="dir " )
149
184
{
150
185
return true ;
0 commit comments