added setting to ignore file modification time when loading resume files

This commit is contained in:
Arvid Norberg 2010-04-11 21:02:43 +00:00
parent ef21d26257
commit 62eef91338
5 changed files with 37 additions and 7 deletions

View File

@ -1,3 +1,4 @@
* added setting to ignore file modification time when loading resume files
* support more fine-grained torrent states between which peer sources it
announces to
* supports calculating sha1 file-hashes when creating torrents

View File

@ -3872,6 +3872,7 @@ session_settings
int default_peer_upload_rate;
int default_peer_download_rate;
bool broadcast_lsd;
bool ignore_resume_timestamps;
};
``user_agent`` this is the client identification to the tracker.
@ -4503,6 +4504,15 @@ if ``broadcast_lsd`` is set to true, the local peer discovery
broadcast its messages. This can be useful when running on networks
that don't support multicast. It's off by default since it's inefficient.
``ignore_resume_timestamps`` determines if the storage, when loading
resume data files, should verify that the file modification time
with the timestamps in the resume data. This defaults to false, which
means timestamps are taken into account, and resume data is less likely
to accepted (torrents are more likely to be fully checked when loaded).
It might be useful to set this to true if your network is faster than your
disk, and it would be faster to redownload potentially missed pieces than
to go through the whole storage to look for them.
pe_settings
===========

View File

@ -211,6 +211,7 @@ namespace libtorrent
, default_peer_upload_rate(0)
, default_peer_download_rate(0)
, broadcast_lsd(false)
, ignore_resume_timestamps(false)
{}
// this is the user agent that will be sent to the tracker
@ -810,6 +811,12 @@ namespace libtorrent
// default in order to avoid flooding networks for no good reason. If
// a network is known not to support multicast, this can be enabled
bool broadcast_lsd;
// when set to true, the file modification time is ignored when loading
// resume data. The resume data includes the expected timestamp of each
// file and is typically compared to make sure the files haven't changed
// since the last session
bool ignore_resume_timestamps;
};
#ifndef TORRENT_DISABLE_DHT

View File

@ -306,6 +306,7 @@ namespace aux {
TORRENT_SETTING(boolean, strict_end_game_mode)
TORRENT_SETTING(integer, default_peer_upload_rate)
TORRENT_SETTING(integer, default_peer_download_rate)
TORRENT_SETTING(boolean, ignore_resume_timestamps)
};
#undef TORRENT_SETTING

View File

@ -187,11 +187,17 @@ namespace libtorrent
// resume data. This is because full allocation will not move
// pieces, so any older version of the resume data will
// still be a correct subset of the actual data on disk.
enum flags_t
{
compact_mode = 1,
ignore_timestamps = 2
};
bool match_filesizes(
file_storage const& fs
, std::string p
, std::vector<std::pair<size_type, std::time_t> > const& sizes
, bool compact_mode
, int flags
, error_code& error)
{
if ((int)sizes.size() != fs.num_files())
@ -220,17 +226,20 @@ namespace libtorrent
time = s.mtime;
}
if ((compact_mode && size != size_iter->first)
|| (!compact_mode && size < size_iter->first))
if (((flags & compact_mode) && size != size_iter->first)
|| (!(flags & compact_mode) && size < size_iter->first))
{
error = errors::mismatching_file_size;
return false;
}
if (flags & ignore_timestamps) continue;
// allow one second 'slack', because of FAT volumes
// in sparse mode, allow the files to be more recent
// than the resume data, but only by 5 minutes
if ((compact_mode && (time > size_iter->second + 1 || time < size_iter->second - 1)) ||
(!compact_mode && (time > size_iter->second + 5 * 60 || time < size_iter->second - 1)))
if (((flags & compact_mode) && (time > size_iter->second + 1 || time < size_iter->second - 1)) ||
(!(flags & compact_mode) && (time > size_iter->second + 5 * 60 || time < size_iter->second - 1)))
{
error = errors::mismatching_file_timestamp;
return false;
@ -823,8 +832,10 @@ namespace libtorrent
}
}
}
return match_filesizes(files(), m_save_path, file_sizes
, !full_allocation_mode, error);
int flags = (full_allocation_mode ? 0 : compact_mode)
| (settings().ignore_resume_timestamps ? ignore_timestamps : 0);
return match_filesizes(files(), m_save_path, file_sizes, flags, error);
}