@@ -1420,52 +1420,67 @@ public function splitFiles($strSrcFile, $strDesFolder, $strDesFile, $intSizeLimi
1420
1420
*
1421
1421
* @CtoCommunication Enable
1422
1422
*
1423
- * @param type $strSplitname
1424
- * @param type $intSplitcount
1425
- * @param type $strMovepath
1426
- * @param type $strMD5
1423
+ * @param string $splitname
1424
+ * @param int|string $splitcount
1425
+ * @param string $movepath
1426
+ * @param string $md5
1427
1427
*
1428
- * @return type
1428
+ * @return boolean
1429
+ *
1430
+ * @throws Exception
1429
1431
*/
1430
- public function rebuildSplitFiles ($ strSplitname , $ intSplitcount , $ strMovepath , $ strMD5 )
1431
- {
1432
- // Build savepath
1433
- $ strSavePath = $ this ->objSyncCtoHelper ->standardizePath ($ GLOBALS ['SYC_PATH ' ]['tmp ' ], "sync " , $ strMovepath );
1432
+ public function rebuildSplitFiles (
1433
+ string $ splitname ,
1434
+ int |string $ splitcount ,
1435
+ string $ movepath ,
1436
+ string $ md5
1437
+ ) {
1438
+ $ strSavePath = $ this
1439
+ ->objSyncCtoHelper
1440
+ ->standardizePath ($ GLOBALS ['SYC_PATH ' ]['tmp ' ], "sync " , $ movepath )
1441
+ ;
1434
1442
1435
1443
// Create Folder
1436
- $ objFolder = new Folder (dirname ($ strSavePath ));
1444
+ try {
1445
+ new Folder (dirname ($ strSavePath ));
1446
+ } catch (Exception $ e ) {
1447
+ throw new Exception (
1448
+ sprintf (
1449
+ 'Could not create folder "%s". Error: %s ' ,
1450
+ dirname ($ strSavePath ),
1451
+ $ e ->getMessage ()
1452
+ )
1453
+ );
1454
+ }
1437
1455
1438
- // Run for each part file
1439
- for ($ i = 0 ; $ i < $ intSplitcount ; $ i ++) {
1440
- // Build path for part file
1441
- $ strReadFile = $ this ->objSyncCtoHelper ->standardizePath ($ GLOBALS ['SYC_PATH ' ]['tmp ' ], $ strSplitname , $ strSplitname . ".sync " . $ i );
1456
+ $ hanFileWhole = fopen (
1457
+ $ this ->objSyncCtoHelper ->getContaoRoot ()
1458
+ . DIRECTORY_SEPARATOR
1459
+ . $ strSavePath ,
1460
+ "a+ "
1461
+ );
1462
+ for ($ i = 0 ; $ i < $ splitcount ; $ i ++) {
1463
+ $ strReadFile = $ this
1464
+ ->objSyncCtoHelper
1465
+ ->standardizePath ($ GLOBALS ['SYC_PATH ' ]['tmp ' ], $ splitname , $ splitname . ".sync " . $ i )
1466
+ ;
1442
1467
1443
1468
// Check if file exists
1444
1469
if (!file_exists ($ this ->objSyncCtoHelper ->getContaoRoot () . DIRECTORY_SEPARATOR . $ strReadFile )) {
1445
- throw new Exception (vsprintf ($ GLOBALS ['TL_LANG ' ]['ERR ' ]['unknown_file ' ], array ($ strSplitname . ".sync " . $ i )));
1470
+ throw new Exception (vsprintf ($ GLOBALS ['TL_LANG ' ]['ERR ' ]['unknown_file ' ], array ($ splitname . ".sync " . $ i )));
1446
1471
}
1447
1472
1448
- // Create new file objects
1449
- $ objFilePart = new File ($ strReadFile );
1450
- $ hanFileWhole = fopen ($ this ->objSyncCtoHelper ->getContaoRoot () . DIRECTORY_SEPARATOR . $ strSavePath , "a+ " );
1451
-
1452
- // Write part file to main file
1453
- fwrite ($ hanFileWhole , $ objFilePart ->getContent ());
1454
-
1455
- // Close objects
1456
- $ objFilePart ->close ();
1457
- fclose ($ hanFileWhole );
1458
-
1459
- // Free up memory
1460
- unset($ objFilePart );
1461
- unset($ hanFileWhole );
1462
-
1463
- // wait
1464
- sleep (1 );
1473
+ fwrite (
1474
+ $ hanFileWhole ,
1475
+ file_get_contents ($ this ->objSyncCtoHelper ->getContaoRoot () . DIRECTORY_SEPARATOR . $ strReadFile )
1476
+ );
1465
1477
}
1466
1478
1479
+ fclose ($ hanFileWhole );
1480
+ unset($ hanFileWhole );
1481
+
1467
1482
// Check MD5 Checksum
1468
- if (md5_file ($ this ->objSyncCtoHelper ->getContaoRoot () . DIRECTORY_SEPARATOR . $ strSavePath ) != $ strMD5 ) {
1483
+ if (md5_file ($ this ->objSyncCtoHelper ->getContaoRoot () . DIRECTORY_SEPARATOR . $ strSavePath ) != $ md5 ) {
1469
1484
throw new Exception ($ GLOBALS ['TL_LANG ' ]['ERR ' ]['checksum_error ' ]);
1470
1485
}
1471
1486
0 commit comments