[zypp-commit] r5882 - in /branches/REFACTORING-10_3/libzypp: tests/zypp/MediaSetAccessTest.cc zypp/MediaSetAccess.cc zypp/MediaSetAccess.h
![](https://seccdn.libravatar.org/avatar/ba30a531854d27405c5e37aae6d3aaad.jpg?s=120&d=mm&r=g)
Author: jkupec Date: Wed Jul 4 16:49:40 2007 New Revision: 5882 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5882&view=rev Log: - catching MediaException only in provide*() from MediaManager::provide*() - comments Modified: branches/REFACTORING-10_3/libzypp/tests/zypp/MediaSetAccessTest.cc branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.cc branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.h Modified: branches/REFACTORING-10_3/libzypp/tests/zypp/MediaSetAccessTest.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/tests/zypp/MediaSetAccessTest.cc?rev=5882&r1=5881&r2=5882&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/tests/zypp/MediaSetAccessTest.cc (original) +++ branches/REFACTORING-10_3/libzypp/tests/zypp/MediaSetAccessTest.cc Wed Jul 4 16:49:40 2007 @@ -11,11 +11,10 @@ using std::endl; using std::string; using namespace zypp; -using namespace zypp::media; using namespace boost::unit_test; -class SimpleVerifier : public zypp::media::MediaVerifierBase +class SimpleVerifier : public media::MediaVerifierBase { public: @@ -127,7 +126,7 @@ // provide file from invalid media BOOST_CHECK_THROW(setaccess.provideFile("/test.txt", 2), - zypp::media::MediaNotDesiredException); + media::MediaNotDesiredException); // provide file from media3 Pathname file3 = setaccess.provideFile("/test.txt", 3); @@ -146,6 +145,11 @@ // provide file from media Pathname file = setaccess.provideFile("/test.txt", 1); BOOST_CHECK(check_file_exists(file) == true); + + // provide non-existent file + // (default answer from callback should be ABORT) + BOOST_CHECK_THROW(setaccess.provideFile("/imnothere", 2), + media::MediaFileNotFoundException); } /* @@ -157,14 +161,24 @@ MediaSetAccess setaccess(url); Pathname dir = setaccess.provideDir("/dir", false, 1); - + Pathname file1 = dir + "/file1"; BOOST_CHECK(check_file_exists(file1) == true); Pathname file2 = dir + "/file2"; BOOST_CHECK(check_file_exists(file2) == true); - //! \todo ensure nothing else is here (e.g. the 'subdir' direcotry) + // provide non-existent dir + // (default answer from callback should be ABORT) + BOOST_CHECK_THROW(setaccess.provideDir("/imnothere", 2), + media::MediaFileNotFoundException); + + // This can't be properly tested with 'dir' schema, probably only curl + // schemas (http, ftp) where download is actually needed. + // Other schemas just get mounted onto a local dir and the whole subtree + // is automatically available that way. + // BOOST_CHECK(check_file_exists(dir + "/subdir/file") == false); + // BOOST_CHECK(check_file_exists(dir + "/subdir") == false); } @@ -176,7 +190,7 @@ Url url(urlstr); MediaSetAccess setaccess(url); - Pathname dir = setaccess.provideDir("/dir", false, 1); + Pathname dir = setaccess.provideDir("/dir", true, 1); Pathname file1 = dir + "/file1"; BOOST_CHECK(check_file_exists(file1) == true); @@ -217,7 +231,8 @@ if (argc < 2) { cout << "mediasetaccesstest:" - " path to directory with test data required as parameter" << endl; + " absolute path to local directory with test data required as parameter" + << endl; return (test_suite *)0; } Modified: branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.cc?rev=5882&r1=5881&r2=5882&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.cc Wed Jul 4 16:49:40 2007 @@ -105,7 +105,7 @@ exists = media_mgr.doesFileExist(media, file); break; } - catch ( Exception & excp ) + catch ( media::MediaException & excp ) { ZYPP_CAUGHT(excp); media::MediaChangeReport::Action user; @@ -207,7 +207,7 @@ media_mgr.provideFile (media, file, false, false); break; } - catch ( Exception & excp ) + catch ( media::MediaException & excp ) { ZYPP_CAUGHT(excp); media::MediaChangeReport::Action user; @@ -339,7 +339,7 @@ break; // quit the retry loop } - catch (Exception & excp) + catch (media::MediaException & excp) { ZYPP_CAUGHT(excp); media::MediaChangeReport::Action user; Modified: branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.h?rev=5882&r1=5881&r2=5882&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.h (original) +++ branches/REFACTORING-10_3/libzypp/zypp/MediaSetAccess.h Wed Jul 4 16:49:40 2007 @@ -92,21 +92,43 @@ * Sets a \ref MediaVerifier verifier for given media number. */ void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier ); - + /** * Provides a file from a media location. + * + * \param on_media_file location of the file on media + * \return local pathname of the requested file + * + * \throws MediaException if a problem occurs, + * see \ref media::MediaManager::provideFile() */ Pathname provideFile( const OnMediaLocation & on_media_file ); /** - * Provides \a file from media \a media_nr. + * Provides \a file from media \a media_nr. + * + * \param file path to the file relative to media URL + * \param media_nr the media number in the media set + * \return local pathname of the requested file + * + * \throws MediaException if a problem occurs, + * see \ref media::MediaManager::provideFile() */ Pathname provideFile(const Pathname & file, unsigned media_nr = 1 ); /** + * Provides direcotry \a dir from media number \a media_nr. * + * \param dir path to the directory relative to media URL + * \param recursive whether to provide the whole directory subtree + * \param media_nr the media number in the media set + * \return local pathname of the requested directory + * + * \throws MediaException if a problem occurs, + * see \ref media::MediaManager::provideDir() + * and \ref media::MediaManager::provideDirTree() */ - Pathname provideDir(const Pathname & file, bool recursive, unsigned media_nr = 1); + Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1); /** * check if a file exists on the specified media -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
jkupec@svn.opensuse.org