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

Method Upload

libs/editor/editor_notes.cpp:157–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void Notes::Upload(osm::OsmOAuth const & auth)
158{
159 std::unique_lock<std::mutex> uploadingNotesLock(m_uploadingNotesMutex, std::defer_lock);
160 if (!uploadingNotesLock.try_lock())
161 {
162 // Do not run more than one uploading task at a time.
163 LOG(LDEBUG, ("OSM notes upload is already running"));
164 return;
165 }
166 std::unique_lock<std::mutex> dataAccessLock(m_dataAccessMutex);
167
168 // Size of m_notes is decreased only in this method.
169 size_t size = m_notes.size();
170 osm::ServerApi06 api(auth);
171
172 while (size > 0)
173 {
174 try
175 {
176 dataAccessLock.unlock();
177 auto const id = api.CreateNote(m_notes.front().m_point, m_notes.front().m_note);
178 dataAccessLock.lock();
179 LOG(LINFO, ("A note uploaded with id", id));
180 }
181 catch (osm::ServerApi06::ServerApi06Exception const & e)
182 {
183 LOG(LERROR, ("Can't upload note.", e.Msg()));
184 // Don't attempt upload for other notes as they will likely suffer from the same error.
185 return;
186 }
187
188 m_notes.pop_front();
189 --size;
190 ++m_uploadedNotesCount;
191 Save(m_fileName, m_notes, m_uploadedNotesCount);
192 }
193}
194
195std::list<Note> Notes::GetNotes() const
196{

Callers 2

UploadChangesMethod · 0.45
CreateUploadTaskMethod · 0.45

Calls 6

unlockMethod · 0.80
frontMethod · 0.80
lockMethod · 0.80
SaveFunction · 0.70
sizeMethod · 0.45
CreateNoteMethod · 0.45

Tested by

no test coverage detected