| 76 | } |
| 77 | |
| 78 | bool FileLocation::check() const { |
| 79 | if (fname.isEmpty() || fname == kInMediaCacheLocation) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | ReadAccessEnabler enabler(_bookmark); |
| 84 | if (enabler.failed()) { |
| 85 | const_cast<FileLocation*>(this)->_bookmark = nullptr; |
| 86 | } |
| 87 | |
| 88 | QFileInfo f(name()); |
| 89 | if (!f.isReadable()) return false; |
| 90 | |
| 91 | quint64 s = f.size(); |
| 92 | if (s > kMaxFileSize) { |
| 93 | DEBUG_LOG(("File location check: Wrong size %1").arg(s)); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | if (s != size) { |
| 98 | DEBUG_LOG(("File location check: Wrong size %1 when should be %2").arg(s).arg(size)); |
| 99 | return false; |
| 100 | } |
| 101 | auto realModified = f.lastModified(); |
| 102 | if (realModified != modified) { |
| 103 | DEBUG_LOG(("File location check: Wrong last modified time %1 when should be %2").arg(realModified.toMSecsSinceEpoch()).arg(modified.toMSecsSinceEpoch())); |
| 104 | return false; |
| 105 | } |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | const QString &FileLocation::name() const { |
| 110 | return _bookmark ? _bookmark->name(fname) : fname; |