diff --git a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java index 706f4b5ce2..918d99a5b3 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java @@ -86,6 +86,7 @@ public class IndexBatchCreator { File osmDirFiles; File indexDirFiles; + File backupUploadedFiles; boolean indexPOI = false; boolean indexTransport = false; @@ -190,6 +191,16 @@ public class IndexBatchCreator { } indexDirFiles = new File(dir); + dir = process.getAttribute("directory_for_uploaded_files"); + if (dir != null) { + File file = new File(dir); + file.mkdirs(); + if (file.exists()) { + backupUploadedFiles = file; + } + } + + if(uploadIndexes){ list = doc.getElementsByTagName("authorization_info"); if(list.getLength() != 1){ @@ -472,7 +483,7 @@ public class IndexBatchCreator { protected void uploadIndexes(Set alreadyUploadedFiles){ for(File f : getSortedFiles(indexDirFiles)){ - if(!alreadyUploadedFiles.contains(f.getName())){ + if(!alreadyUploadedFiles.contains(f.getName()) && !f.isDirectory()){ uploadIndex(f, alreadyUploadedFiles); if(!alreadyUploadedFiles.contains(f.getName())){ System.out.println("! NOT UPLOADED " + f.getName()); @@ -580,13 +591,21 @@ public class IndexBatchCreator { List splittedFiles = Collections.emptyList(); try { splittedFiles = splitFiles(toUpload); - boolean uploaded =true; + boolean uploaded = true; for (File fs : splittedFiles) { uploaded &= uploadFileToServer(fs, toUpload, summary); } // remove source file if file was splitted - if (uploaded && deleteFilesAfterUploading && toUpload.exists()) { - toUpload.delete(); + if (uploaded) { + if (deleteFilesAfterUploading && toUpload.exists()) { + toUpload.delete(); + } else if (backupUploadedFiles != null) { + File toBackup = new File(backupUploadedFiles, toUpload.getName()); + if(toBackup.exists()){ + toBackup.delete(); + } + toUpload.renameTo(toBackup); + } } alreadyUploadedFiles.add(fileName); } catch (IOException e) { @@ -642,6 +661,18 @@ public class IndexBatchCreator { if (uploadToOsmandGooglecode) { try { DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName(), token, pagegen, cookieHSID, cookieSID); + if(f.getName().endsWith("obf.zip") && f.length() / MB < 5){ + // try to delete without .zip part + DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName().substring(0, f.getName().length() - 4), + token, pagegen, cookieHSID, cookieSID); + } else if(f.getName().endsWith("poi.zip") && f.length() / MB < 5){ + // try to delete without .zip part + DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName().substring(0, f.getName().length() - 3) +"odb", + token, pagegen, cookieHSID, cookieSID); + } else if(f.getName().endsWith(".zip-1") && f.length() / MB < 10){ + DownloaderIndexFromGoogleCode.deleteFileFromGoogleDownloads(f.getName().substring(0, f.getName().length() - 2), + token, pagegen, cookieHSID, cookieSID); + } try { Thread.sleep(4000); } catch (InterruptedException e) { diff --git a/DataExtractionOSM/src/net/osmand/data/index/batch.xml b/DataExtractionOSM/src/net/osmand/data/index/batch.xml index 41534306ce..24a433dc10 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/batch.xml +++ b/DataExtractionOSM/src/net/osmand/data/index/batch.xml @@ -16,12 +16,14 @@ - + + + + + + + + + - + @@ -81,14 +91,14 @@ - + - + @@ -115,7 +125,7 @@ - + @@ -136,99 +146,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -315,7 +234,7 @@ - + @@ -334,15 +253,13 @@ - - - + - + @@ -350,7 +267,7 @@ - + @@ -365,7 +282,7 @@ - + @@ -377,7 +294,7 @@ - + @@ -395,41 +312,198 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + +