Changeset 1872
- Timestamp:
- 17/10/2007 13:44:49 (4 years ago)
- File:
-
- 1 edited
-
box/trunk/bin/bbackupd/BackupDaemon.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupd/BackupDaemon.cpp
r1863 r1872 1665 1665 BOX_TRACE("new location: " << i->first); 1666 1666 // Create a record for it 1667 Location *ploc = new Location; 1667 std::auto_ptr<Location> apLoc(new Location); 1668 1668 1669 try 1669 1670 { 1670 1671 // Setup names in the location record 1671 ploc->mName = i->first;1672 ploc->mPath = i->second.GetKeyValue("Path");1672 apLoc->mName = i->first; 1673 apLoc->mPath = i->second.GetKeyValue("Path"); 1673 1674 1674 1675 // Read the exclude lists from the Configuration 1675 ploc->mpExcludeFiles = BackupClientMakeExcludeList_Files(i->second); 1676 ploc->mpExcludeDirs = BackupClientMakeExcludeList_Dirs(i->second); 1676 apLoc->mpExcludeFiles = BackupClientMakeExcludeList_Files(i->second); 1677 apLoc->mpExcludeDirs = BackupClientMakeExcludeList_Dirs(i->second); 1678 1677 1679 // Does this exist on the server? 1678 1680 // Remove from dir object early, so that if we fail … … 1680 1682 // consider to remote one for deletion. 1681 1683 BackupStoreDirectory::Iterator iter(dir); 1682 BackupStoreFilenameClear dirname( ploc->mName); // generate the filename1684 BackupStoreFilenameClear dirname(apLoc->mName); // generate the filename 1683 1685 BackupStoreDirectory::Entry *en = iter.FindMatchingClearName(dirname); 1684 1686 int64_t oid = 0; … … 1700 1702 #ifdef HAVE_STRUCT_STATVFS_F_MNTONNAME 1701 1703 struct statvfs s; 1702 if(::statvfs( ploc->mPath.c_str(), &s) != 0)1704 if(::statvfs(apLoc->mPath.c_str(), &s) != 0) 1703 1705 #else // HAVE_STRUCT_STATVFS_F_MNTONNAME 1704 1706 struct statfs s; 1705 if(::statfs( ploc->mPath.c_str(), &s) != 0)1707 if(::statfs(apLoc->mPath.c_str(), &s) != 0) 1706 1708 #endif // HAVE_STRUCT_STATVFS_F_MNTONNAME 1707 1709 { 1708 BOX_WARNING("Failed to stat location: " 1709 << ploc->mPath 1710 << ": " << strerror(errno)); 1711 THROW_EXCEPTION(CommonException, 1712 OSFileError) 1710 BOX_WARNING("Failed to stat location " 1711 "path '" << apLoc->mPath << 1712 "' (" << strerror(errno) << 1713 "), skipping location '" << 1714 apLoc->mName << "'"); 1715 continue; 1713 1716 } 1714 1717 … … 1719 1722 1720 1723 // Warn in logs if the directory isn't absolute 1721 if( ploc->mPath[0] != '/')1724 if(apLoc->mPath[0] != '/') 1722 1725 { 1723 1726 BOX_WARNING("Location path '" 1724 << ploc->mPath1727 << apLoc->mPath 1725 1728 << "' is not absolute"); 1726 1729 } … … 1737 1740 // (sorting order ensures this) 1738 1741 BOX_TRACE("checking against mount point " << *i); 1739 if(::strncmp(i->c_str(), ploc->mPath.c_str(), i->size()) == 0)1742 if(::strncmp(i->c_str(), apLoc->mPath.c_str(), i->size()) == 0) 1740 1743 { 1741 1744 // Match … … 1745 1748 } 1746 1749 BOX_TRACE("mount point chosen for " 1747 << ploc->mPath << " is "1750 << apLoc->mPath << " is " 1748 1751 << mountName); 1749 1752 } … … 1756 1759 { 1757 1760 // Yes -- store the index 1758 ploc->mIDMapIndex = f->second;1761 apLoc->mIDMapIndex = f->second; 1759 1762 } 1760 1763 else 1761 1764 { 1762 1765 // No -- new index 1763 ploc->mIDMapIndex = numIDMaps;1766 apLoc->mIDMapIndex = numIDMaps; 1764 1767 mounts[mountName] = numIDMaps; 1765 1768 … … 1781 1784 try 1782 1785 { 1783 attr.ReadAttributes( ploc->mPath.c_str(),1786 attr.ReadAttributes(apLoc->mPath.c_str(), 1784 1787 true /* directories have zero mod times */, 1785 1788 0 /* not interested in mod time */, … … 1789 1792 { 1790 1793 BOX_ERROR("Failed to get attributes " 1791 "for path '" << ploc->mPath 1792 << "', skipping."); 1794 "for path '" << apLoc->mPath 1795 << "', skipping location '" << 1796 apLoc->mName << "'"); 1793 1797 continue; 1794 1798 } … … 1798 1802 { 1799 1803 MemBlockStream attrStream(attr); 1800 std::auto_ptr<BackupProtocolClientSuccess> dirCreate(connection.QueryCreateDirectory( 1804 std::auto_ptr<BackupProtocolClientSuccess> 1805 dirCreate(connection.QueryCreateDirectory( 1801 1806 BackupProtocolClientListDirectory::RootDirectory, 1802 1807 attrModTime, dirname, attrStream)); … … 1808 1813 { 1809 1814 BOX_ERROR("Failed to create remote " 1810 "directory '/" << ploc->mName << 1811 "', skipping location."); 1815 "directory '/" << apLoc->mName << 1816 "', skipping location '" << 1817 apLoc->mName << "'"); 1812 1818 continue; 1813 1819 } … … 1818 1824 ASSERT(oid != 0); 1819 1825 BackupClientDirectoryRecord *precord = new BackupClientDirectoryRecord(oid, i->first); 1820 ploc->mpDirectoryRecord.reset(precord);1826 apLoc->mpDirectoryRecord.reset(precord); 1821 1827 1822 1828 // Push it back on the vector of locations 1823 mLocations.push_back( ploc);1829 mLocations.push_back(apLoc.release()); 1824 1830 } 1825 1831 catch (std::exception &e) 1826 1832 { 1827 1833 BOX_ERROR("Failed to configure location '" 1828 << ploc->mName << "' path '"1829 << ploc->mPath << "': " << e.what() <<1834 << apLoc->mName << "' path '" 1835 << apLoc->mPath << "': " << e.what() << 1830 1836 ": please check for previous errors"); 1831 delete ploc;1832 ploc = 0;1833 1837 throw; 1834 1838 } … … 1836 1840 { 1837 1841 BOX_ERROR("Failed to configure location '" 1838 << ploc->mName << "' path '"1839 << ploc->mPath << "': please check for "1842 << apLoc->mName << "' path '" 1843 << apLoc->mPath << "': please check for " 1840 1844 "previous errors"); 1841 1842 delete ploc;1843 ploc = NULL;1844 1845 1845 throw; 1846 1846 }
Note: See TracChangeset
for help on using the changeset viewer.
