108 return ""; |
108 return ""; |
109 } |
109 } |
110 |
110 |
111 // ============================================================================= |
111 // ============================================================================= |
112 // ----------------------------------------------------------------------------- |
112 // ----------------------------------------------------------------------------- |
113 void PartDownloader::modifyDest (str& dest) const |
113 void PartDownloader::modifyDestination (str& dest) const |
114 { dest = dest.simplified(); |
114 { dest = dest.simplified(); |
115 |
115 |
116 // If the user doesn't want us to guess, stop right here. |
116 // If the user doesn't want us to guess, stop right here. |
117 if (net_guesspaths == false) |
117 if (net_guesspaths == false) |
118 return; |
118 return; |
200 setAborted (false); |
200 setAborted (false); |
201 |
201 |
202 if (getSource() == CustomURL) |
202 if (getSource() == CustomURL) |
203 dest = basename (getURL()); |
203 dest = basename (getURL()); |
204 |
204 |
205 modifyDest (dest); |
205 modifyDestination (dest); |
206 |
206 |
207 if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) |
207 if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) |
208 { const str overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest); |
208 { const str overwritemsg = fmt (tr ("%1 already exists in download directory. Overwrite?"), dest); |
209 if (!confirm (tr ("Overwrite?"), overwritemsg)) |
209 if (!confirm (tr ("Overwrite?"), overwritemsg)) |
210 return; |
210 return; |
228 |
228 |
229 // Don't download files repeadetly. |
229 // Don't download files repeadetly. |
230 if (m_filesToDownload.indexOf (dest) != -1) |
230 if (m_filesToDownload.indexOf (dest) != -1) |
231 return; |
231 return; |
232 |
232 |
233 modifyDest (dest); |
233 modifyDestination (dest); |
234 log ("DOWNLOAD: %1 -> %2\n", url, PartDownloader::getDownloadPath() + DIRSLASH + dest); |
234 log ("DOWNLOAD: %1 -> %2\n", url, PartDownloader::getDownloadPath() + DIRSLASH + dest); |
235 PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this); |
235 PartDownloadRequest* req = new PartDownloadRequest (url, dest, primary, this); |
236 |
236 |
237 m_filesToDownload << dest; |
237 m_filesToDownload << dest; |
238 m_requests << req; |
238 m_requests << req; |
262 |
262 |
263 // Update everything now |
263 // Update everything now |
264 if (primaryFile()) |
264 if (primaryFile()) |
265 { LDFile::setCurrent (primaryFile()); |
265 { LDFile::setCurrent (primaryFile()); |
266 reloadAllSubfiles(); |
266 reloadAllSubfiles(); |
267 g_win->fullRefresh(); |
267 g_win->doFullRefresh(); |
268 g_win->R()->resetAngles(); |
268 g_win->R()->resetAngles(); |
269 } |
269 } |
270 |
270 |
271 if (net_autoclose && !failed) |
271 if (net_autoclose && !failed) |
272 { // Close automatically if desired. |
272 { // Close automatically if desired. |
428 |
428 |
429 if (!err || err->fileRef().isEmpty()) |
429 if (!err || err->fileRef().isEmpty()) |
430 continue; |
430 continue; |
431 |
431 |
432 str dest = err->fileRef(); |
432 str dest = err->fileRef(); |
433 m_prompt->modifyDest (dest); |
433 m_prompt->modifyDestination (dest); |
434 m_prompt->downloadFile (dest, str (PartDownloader::k_UnofficialURL) + dest, false); |
434 m_prompt->downloadFile (dest, str (PartDownloader::k_UnofficialURL) + dest, false); |
435 } |
435 } |
436 |
436 |
437 if (m_primary) |
437 if (m_primary) |
438 { addRecentFile (m_fpath); |
438 { addRecentFile (m_fpath); |