Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-12-16 15:11:56 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:30:23 +0300
commit2f8c21c44b08d8205c28ff65d509969d67e31c38 (patch)
treef6722c8976c100b66f4d157c42963920dba410ca /platform/http_request.cpp
parentc5ad7cb730aa6229f2f010031e2e99389fa56782 (diff)
[ios] Added "Do not backup to iCloud" attribute for all downloaded map files
Diffstat (limited to 'platform/http_request.cpp')
-rw-r--r--platform/http_request.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/platform/http_request.cpp b/platform/http_request.cpp
index 60a52931ee..50a63922a7 100644
--- a/platform/http_request.cpp
+++ b/platform/http_request.cpp
@@ -9,12 +9,28 @@
#endif
#include "../base/std_serialization.hpp"
+#include "../base/logging.hpp"
#include "../coding/file_writer_stream.hpp"
#include "../coding/file_reader_stream.hpp"
#include "../std/scoped_ptr.hpp"
+#ifdef OMIM_OS_IPHONE
+
+#include <sys/xattr.h>
+
+void DisableiCloudBackupForFile(string const & filePath)
+{
+ static char const * attrName = "com.apple.MobileBackup";
+ u_int8_t attrValue = 1;
+ const int result = setxattr(filePath.c_str(), attrName, &attrValue, sizeof(attrValue), 0, 0);
+ if (result != 0)
+ LOG(LWARNING, ("Error while disabling iCloud backup for file", filePath));
+}
+
+#endif // OMIM_OS_IPHONE
+
class HttpThread;
namespace downloader
@@ -166,6 +182,11 @@ class FileHttpRequest : public HttpRequest, public IHttpThreadCallback
FileWriter::DeleteFileX(m_filePath + RESUME_FILE_EXTENSION);
// rename finished file to it's original name
rename((m_filePath + DOWNLOADING_FILE_EXTENSION).c_str(), m_filePath.c_str());
+#ifdef OMIM_OS_IPHONE
+ // We need to disable iCloud backup for downloaded files.
+ // This is the reason for rejecting from the AppStore
+ DisableiCloudBackupForFile(m_filePath.c_str());
+#endif
}
else // or save "chunks left" otherwise
SaveRanges(m_filePath + RESUME_FILE_EXTENSION, m_strategy.ChunksLeft());
@@ -199,6 +220,9 @@ class FileHttpRequest : public HttpRequest, public IHttpThreadCallback
FileWriterStream fws(file);
fws << ranges;
}
+#ifdef OMIM_OS_IPHONE
+ DisableiCloudBackupForFile(file);
+#endif
}
struct CalcRanges
@@ -234,6 +258,10 @@ public:
m_strategy.SetChunksToDownload(ranges);
}
+#ifdef OMIM_OS_IPHONE
+ m_writer->Flush();
+ DisableiCloudBackupForFile(filePath + DOWNLOADING_FILE_EXTENSION);
+#endif
StartThreads();
}