diff data/fileio/CachedFile.cpp @ 742:c10cb8782576 coreaudio_tests

Merge from branch "default"
author Chris Cannam
date Sun, 01 Jul 2012 11:53:00 +0100
parents b99dc5465b80
children e802e550a1f2
line wrap: on
line diff
--- a/data/fileio/CachedFile.cpp	Mon Nov 29 12:45:39 2010 +0000
+++ b/data/fileio/CachedFile.cpp	Sun Jul 01 11:53:00 2012 +0100
@@ -78,9 +78,9 @@
 {
     Profiler p("CachedFile::CachedFile[1]");
 
-    std::cerr << "CachedFile::CachedFile: origin is \""
-              << origin.toStdString() << "\"" << std::endl;
-    check();
+    SVDEBUG << "CachedFile::CachedFile: origin is \""
+              << origin << "\"" << endl;
+    checkFile();
 }
 
 CachedFile::CachedFile(QUrl url,
@@ -93,9 +93,9 @@
 {
     Profiler p("CachedFile::CachedFile[2]");
 
-    std::cerr << "CachedFile::CachedFile: url is \""
-              << url.toString().toStdString() << "\"" << std::endl;
-    check();
+    SVDEBUG << "CachedFile::CachedFile: url is \""
+              << url.toString() << "\"" << endl;
+    checkFile();
 }
 
 CachedFile::~CachedFile()
@@ -115,7 +115,7 @@
 }
 
 void
-CachedFile::check()
+CachedFile::checkFile()
 {
     //!!! n.b. obvious race condition here if different CachedFile
     // objects for same url used in more than one thread -- need to
@@ -132,20 +132,20 @@
     m_localFilename = getLocalFilenameFor(m_origin);
 
     if (!QFileInfo(m_localFilename).exists()) {
-        std::cerr << "CachedFile::check: Local file does not exist, making a note that it hasn't been retrieved" << std::endl;
+        SVDEBUG << "CachedFile::check: Local file does not exist, making a note that it hasn't been retrieved" << endl;
         updateLastRetrieval(false); // empirically!
     }
 
     QDateTime lastRetrieval = getLastRetrieval();
 
     if (lastRetrieval.isValid()) {
-        std::cerr << "CachedFile::check: Valid last retrieval at "
-                  << lastRetrieval.toString().toStdString() << std::endl;
+        SVDEBUG << "CachedFile::check: Valid last retrieval at "
+                  << lastRetrieval.toString() << endl;
         // this will not be the case if the file is missing, after
         // updateLastRetrieval(false) was called above
         m_ok = true;
         if (lastRetrieval.addDays(2) < QDateTime::currentDateTime()) { //!!!
-            std::cerr << "CachedFile::check: Out of date; trying to retrieve again" << std::endl;
+            SVDEBUG << "CachedFile::check: Out of date; trying to retrieve again" << endl;
             // doesn't matter if retrieval fails -- we just don't
             // update the last retrieval time
 
@@ -154,17 +154,17 @@
             // retrieval every single time if it isn't working
 
             if (retrieve()) {
-                std::cerr << "CachedFile::check: Retrieval succeeded" << std::endl;
+                SVDEBUG << "CachedFile::check: Retrieval succeeded" << endl;
                 updateLastRetrieval(true);
             } else {
                 std::cerr << "CachedFile::check: Retrieval failed, will try again later (using existing file for now)" << std::endl;
             }                
         }
     } else {
-        std::cerr << "CachedFile::check: No valid last retrieval" << std::endl;
+        SVDEBUG << "CachedFile::check: No valid last retrieval" << endl;
         // there is no acceptable file
         if (retrieve()) {
-            std::cerr << "CachedFile::check: Retrieval succeeded" << std::endl;
+            SVDEBUG << "CachedFile::check: Retrieval succeeded" << endl;
             m_ok = true;
             updateLastRetrieval(true);
         } else {
@@ -191,28 +191,28 @@
     FileSource fs(m_origin, m_reporter, m_preferredContentType);
 
     if (!fs.isOK() || !fs.isAvailable()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << std::endl;
+        SVDEBUG << "CachedFile::retrieve: ERROR: FileSource reported unavailable or failure" << endl;
         return false;
     }
 
     fs.waitForData();
 
     if (!fs.isOK()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported failure during receive" << std::endl;
+        SVDEBUG << "CachedFile::retrieve: ERROR: FileSource reported failure during receive" << endl;
         return false;
     }
 
     QString tempName = fs.getLocalFilename();
     QFile tempFile(tempName);
     if (!tempFile.exists()) {
-        std::cerr << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName.toStdString() << "\" does not exist" << std::endl;
+        SVDEBUG << "CachedFile::retrieve: ERROR: FileSource reported success, but local temporary file \"" << tempName << "\" does not exist" << endl;
         return false;
     }
 
     QFile previous(m_localFilename);
     if (previous.exists()) {
         if (!previous.remove()) {
-            std::cerr << "CachedFile::retrieve: ERROR: Failed to remove previous copy of cached file at \"" << m_localFilename.toStdString() << "\"" << std::endl;
+            std::cerr << "CachedFile::retrieve: ERROR: Failed to remove previous copy of cached file at \"" << m_localFilename << "\"" << std::endl;
             return false;
         }
     }
@@ -222,11 +222,11 @@
     //!!! disk space left)
 
     if (!tempFile.copy(m_localFilename)) {
-        std::cerr << "CachedFile::retrieve: ERROR: Failed to copy newly retrieved file from \"" << tempName.toStdString() << "\" to \"" << m_localFilename.toStdString() << "\"" << std::endl;
+        std::cerr << "CachedFile::retrieve: ERROR: Failed to copy newly retrieved file from \"" << tempName << "\" to \"" << m_localFilename << "\"" << std::endl;
         return false;
     }
 
-    std::cerr << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName.toStdString() << "\" to its home at \"" << m_localFilename.toStdString() << "\"" << std::endl;
+    SVDEBUG << "CachedFile::retrieve: Successfully copied newly retrieved file \"" << tempName << "\" to its home at \"" << m_localFilename << "\"" << endl;
 
     return true;
 }