/** \relates CheckSum Stream output. */
std::ostream & operator<<( std::ostream & str, const CheckSum & obj )
- { return str << (obj.empty() ? std::string("NoCheckSum")
- : obj.type()+"-"+obj.checksum() ); }
+ { return str << (obj.empty() ? std::string("(no checksum)")
+ : obj.type()+":"+obj.checksum() ); }
/** \relates CheckSum */
bool operator==( const CheckSum & lhs, const CheckSum & rhs )
///////////////////////////////////////////////////////////////////
ChecksumFileChecker::ChecksumFileChecker( const CheckSum &checksum )
+ : _checksum(checksum)
{
-
}
bool ChecksumFileChecker::operator()( const Pathname &file )
{
-
+ // FIXME probably this funcionality should be in CheckSum itself
+ CheckSum real_checksum( _checksum.type(), filesystem::checksum( file, _checksum.type() ));
+ if ( real_checksum == _checksum )
+ {
+ return true;
+ }
+ else
+ {
+ ERR << "Got " << real_checksum << ", expected " << _checksum << std::endl;
+ return false;
+ }
}
MediaSetAccess::MediaSetAccess( const Url &url, const Pathname &path )
return provideFileInternal( file, media_nr, false, false);
}
- const Pathname MediaSetAccess::tryToProvideFile(const Pathname & file, const unsigned media_nr )
+ const Pathname MediaSetAccess::provideFile(const Pathname & file, const unsigned media_nr, FileChecker checker )
{
- return provideFileInternal( file, media_nr, false, false);
+ Pathname p = provideFileInternal( file, media_nr, false, false);
+
+ if ( ! checker(p) )
+ {
+ ZYPP_THROW(Exception("Error checker"));
+ }
+ return p;
}
const Pathname MediaSetAccess::provideFileInternal(const Pathname & file, const unsigned media_nr, bool cached, bool checkonly )
*/
void setVerifiers( const std::vector<media::MediaVerifierRef> &verifiers );
const Pathname provideFile(const Pathname & file, const unsigned media_nr = 1 );
- const Pathname tryToProvideFile(const Pathname & file, const unsigned media_nr = 1 );
+ const Pathname provideFile(const Pathname & file, const unsigned media_nr, const FileChecker checker );
protected:
const Pathname provideFileInternal(const Pathname & file, const unsigned media_nr, bool checkonly, bool cached);
Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
MIL << "Done reading key" << std::endl;
}
- Impl(const std::istream &data)
- {}
-
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
: _pimpl( Impl::nullimpl() )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PublicKey::PublicKey
- // METHOD TYPE : Ctor
- //
- PublicKey::PublicKey( const std::istream &data )
- : _pimpl( new Impl(data) )
- {}
-
PublicKey::PublicKey( const Pathname &file )
: _pimpl( new Impl(file) )
{}
/** Ctor
* \throws when data does not make a key
*/
- PublicKey(const std::istream &data);
PublicKey(const Pathname &file);
~PublicKey();