MCPcopy Create free account
hub / github.com/comaps/comaps / HandleFile

Method HandleFile

libs/tracking/archival_file.cpp:31–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace archival_file
30{
31void FilesAccumulator::HandleFile(std::string const & fileName)
32{
33 uint64_t fileSize = 0;
34 if (!Platform::GetFileSizeByFullPath(fileName, fileSize))
35 {
36 LOG(LDEBUG, ("File does not exist", fileName));
37 return;
38 }
39 if (fileSize == 0)
40 {
41 LOG(LDEBUG, ("File is empty", fileName));
42 base::DeleteFileX(fileName);
43 return;
44 }
45 if (fileSize > kMaxFilesTotalSizeToSendBytes)
46 {
47 LOG(LDEBUG, ("File is too large", fileName, fileSize));
48 base::DeleteFileX(fileName);
49 return;
50 }
51
52 FileInfo const meta = ParseArchiveFilename(fileName);
53 auto const insData = m_filesByType.emplace(meta.m_trackType, FilesBatch());
54 auto const it = insData.first;
55 auto & fileBatch = it->second;
56 if (!insData.second)
57 {
58 if (fileBatch.m_totalSize + fileSize > kMaxFilesTotalSizeToSendBytes)
59 return;
60 }
61
62 fileBatch.m_totalSize += fileSize;
63 fileBatch.m_files.push_back(fileName);
64}
65
66std::vector<std::string> FilesAccumulator::PrepareArchives(std::string const & path)
67{

Callers 1

PrepareUploadMethod · 0.80

Calls 5

DeleteFileXFunction · 0.85
ParseArchiveFilenameFunction · 0.85
FilesBatchClass · 0.85
emplaceMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected