| 1752 | } |
| 1753 | |
| 1754 | void Account::writeFileLocation(MediaKey location, const Core::FileLocation &local) { |
| 1755 | if (local.fname.isEmpty()) { |
| 1756 | return; |
| 1757 | } |
| 1758 | if (!local.inMediaCache()) { |
| 1759 | const auto aliasIt = _fileLocationAliases.constFind(location); |
| 1760 | if (aliasIt != _fileLocationAliases.cend()) { |
| 1761 | location = aliasIt.value(); |
| 1762 | } |
| 1763 | |
| 1764 | const auto i = _fileLocationPairs.find(local.fname); |
| 1765 | if (i != _fileLocationPairs.cend()) { |
| 1766 | if (i.value().second == local) { |
| 1767 | if (i.value().first != location) { |
| 1768 | _fileLocationAliases.insert(location, i.value().first); |
| 1769 | writeLocationsQueued(); |
| 1770 | } |
| 1771 | return; |
| 1772 | } |
| 1773 | if (i.value().first != location) { |
| 1774 | for (auto j = _fileLocations.find(i.value().first), e = _fileLocations.end(); (j != e) && (j.key() == i.value().first); ++j) { |
| 1775 | if (j.value() == i.value().second) { |
| 1776 | _fileLocations.erase(j); |
| 1777 | break; |
| 1778 | } |
| 1779 | } |
| 1780 | _fileLocationPairs.erase(i); |
| 1781 | } |
| 1782 | } |
| 1783 | _fileLocationPairs.insert(local.fname, { location, local }); |
| 1784 | } else { |
| 1785 | for (auto i = _fileLocations.find(location); (i != _fileLocations.end()) && (i.key() == location);) { |
| 1786 | if (i.value().inMediaCache() || i.value().check()) { |
| 1787 | return; |
| 1788 | } |
| 1789 | i = _fileLocations.erase(i); |
| 1790 | } |
| 1791 | } |
| 1792 | _fileLocations.insert(location, local); |
| 1793 | writeLocationsQueued(); |
| 1794 | } |
| 1795 | |
| 1796 | void Account::removeFileLocation(MediaKey location) { |
| 1797 | auto i = _fileLocations.find(location); |
no test coverage detected