libzypp  17.25.2
MediaSetAccess.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
10 #include <iostream>
11 #include <fstream>
12 
13 #include <zypp/base/LogTools.h>
14 #include <zypp/base/Regex.h>
16 #include <zypp/ZYppCallbacks.h>
17 #include <zypp/MediaSetAccess.h>
18 #include <zypp/PathInfo.h>
19 #include <zypp/TmpPath.h>
20 //#include <zypp/source/MediaSetAccessReportReceivers.h>
21 
22 using std::endl;
23 
25 namespace zypp
26 {
27 
29 
31 
33  const Pathname & prefered_attach_point)
34  : _url(url)
35  , _prefAttachPoint(prefered_attach_point)
36  {}
37 
38  MediaSetAccess::MediaSetAccess(const std::string & label_r,
39  const Url &url,
40  const Pathname & prefered_attach_point)
41  : _url(url)
42  , _prefAttachPoint(prefered_attach_point)
43  , _label( label_r )
44  {}
45 
47  {
48  try
49  {
50  media::MediaManager manager;
51  for ( const auto & mm : _medias )
52  manager.close( mm.second );
53  }
54  catch(...) {} // don't let exception escape a dtor.
55  }
56 
57 
59  {
60  if (_medias.find(media_nr) != _medias.end())
61  {
62  // the media already exists, set theverifier
63  media::MediaAccessId id = _medias[media_nr];
64  media::MediaManager media_mgr;
65  media_mgr.addVerifier( id, verifier );
66  // remove any saved verifier for this media
67  _verifiers.erase(media_nr);
68  }
69  else
70  {
71  // save the verifier in the map, and set it when
72  // the media number is first attached
73  _verifiers[media_nr] = verifier;
74  }
75  }
76 
77  void MediaSetAccess::releaseFile( const OnMediaLocation & on_media_file )
78  {
79  releaseFile( on_media_file.filename(), on_media_file.medianr() );
80  }
81 
82  void MediaSetAccess::releaseFile( const Pathname & file, unsigned media_nr)
83  {
84  media::MediaManager media_mgr;
86 
87  media = getMediaAccessId( media_nr);
88  DBG << "Going to release file " << file
89  << " from media number " << media_nr << endl;
90 
91  if ( ! media_mgr.isAttached(media) )
92  return; //disattached media is free
93 
94  media_mgr.releaseFile (media, file);
95  }
96 
98  bool dots, unsigned media_nr )
99  {
100  media::MediaManager media_mgr;
101  media::MediaAccessId media;
102  media = getMediaAccessId(media_nr);
103 
104  // try to attach the media
105  if ( ! media_mgr.isAttached(media) )
106  media_mgr.attach(media);
107 
108  media_mgr.dirInfo(media, retlist, dirname, dots);
109  }
110 
112  {
115  void operator()( media::MediaAccessId media, const Pathname &file )
116  {
117  media::MediaManager media_mgr;
118  media_mgr.provideFile(media, file, expectedFileSize);
119  result = media_mgr.localPath(media, file);
120  }
121  };
122 
124  {
126  void operator()( media::MediaAccessId media, const Pathname &file )
127  {
128  media::MediaManager media_mgr;
129  media_mgr.provideDirTree(media, file);
130  result = media_mgr.localPath(media, file);
131  }
132  };
133 
135  {
137  void operator()( media::MediaAccessId media, const Pathname &file )
138  {
139  media::MediaManager media_mgr;
140  media_mgr.provideDir(media, file);
141  result = media_mgr.localPath(media, file);
142  }
143  };
144 
146  {
147  bool result;
149  : result(false)
150  {}
151 
152  void operator()( media::MediaAccessId media, const Pathname &file )
153  {
154  media::MediaManager media_mgr;
155  result = media_mgr.doesFileExist(media, file);
156  }
157  };
158 
159 
160 
161  Pathname MediaSetAccess::provideFile( const OnMediaLocation & resource, ProvideFileOptions options, const Pathname &deltafile )
162  {
164  op.expectedFileSize = resource.downloadSize();
165  provide( boost::ref(op), resource, options, deltafile );
166  return op.result;
167  }
168 
169  Pathname MediaSetAccess::provideFile(const Pathname & file, unsigned media_nr, ProvideFileOptions options )
170  {
171  OnMediaLocation resource;
173  resource.setLocation(file, media_nr);
174  provide( boost::ref(op), resource, options, Pathname() );
175  return op.result;
176  }
177 
178  Pathname MediaSetAccess::provideOptionalFile( const Pathname & file, unsigned media_nr )
179  {
180  try
181  {
182  if ( doesFileExist( file, media_nr ) )
183  return provideFile( file, media_nr, PROVIDE_NON_INTERACTIVE );
184  }
185  catch ( const media::MediaFileNotFoundException & excpt_r )
186  { ZYPP_CAUGHT( excpt_r ); }
187  catch ( const media::MediaNotAFileException & excpt_r )
188  { ZYPP_CAUGHT( excpt_r ); }
189  return Pathname();
190  }
191 
192  ManagedFile MediaSetAccess::provideFileFromUrl(const Url &file_url, ProvideFileOptions options)
193  {
194  Url url(file_url);
195  Pathname path(url.getPathName());
196  url.setPathName ("/");
197  MediaSetAccess access(url);
198 
200 
201  Pathname file = access.provideFile(path, 1, options);
202 
203  //prevent the file from being deleted when MediaSetAccess gets out of scope
204  if ( filesystem::hardlinkCopy(file, tmpFile) != 0 )
205  ZYPP_THROW(Exception("Can't copy file from " + file.asString() + " to " + tmpFile->asString() ));
206 
207  return tmpFile;
208  }
209 
211  {
212  try
213  {
214  return provideFileFromUrl( file_url, PROVIDE_NON_INTERACTIVE );
215  }
216  catch ( const media::MediaFileNotFoundException & excpt_r )
217  { ZYPP_CAUGHT( excpt_r ); }
218  catch ( const media::MediaNotAFileException & excpt_r )
219  { ZYPP_CAUGHT( excpt_r ); }
220  return ManagedFile();
221  }
222 
223  bool MediaSetAccess::doesFileExist(const Pathname & file, unsigned media_nr )
224  {
226  OnMediaLocation resource;
227  resource.setLocation(file, media_nr);
228  provide( boost::ref(op), resource, PROVIDE_DEFAULT, Pathname());
229  return op.result;
230  }
231 
232  void MediaSetAccess::precacheFiles(const std::vector<OnMediaLocation> &files)
233  {
234  media::MediaManager media_mgr;
235 
236  for ( const auto &resource : files ) {
237  Pathname file(resource.filename());
238  unsigned media_nr(resource.medianr());
239  media::MediaAccessId media = getMediaAccessId( media_nr );
240 
241  if ( !media_mgr.isOpen( media ) ) {
242  MIL << "Skipping precache of file " << resource.filename() << " media is not open";
243  continue;
244  }
245 
246  if ( ! media_mgr.isAttached(media) )
247  media_mgr.attach(media);
248 
249  media_mgr.precacheFiles( media, { resource } );
250  }
251  }
252 
254  const OnMediaLocation &resource,
255  ProvideFileOptions options,
256  const Pathname &deltafile )
257  {
258  Pathname file(resource.filename());
259  unsigned media_nr(resource.medianr());
260 
262  media::MediaManager media_mgr;
263 
264  media::MediaAccessId media;
265 
266  do
267  {
268  // get the mediaId, but don't try to attach it here
269  media = getMediaAccessId( media_nr);
270  bool deltafileset = false;
271 
272  try
273  {
274  DBG << "Going to try to provide " << (resource.optional() ? "optional" : "") << " file " << file
275  << " from media number " << media_nr << endl;
276  // try to attach the media
277  if ( ! media_mgr.isAttached(media) )
278  media_mgr.attach(media);
279  media_mgr.setDeltafile(media, deltafile);
280  deltafileset = true;
281  op(media, file);
282  media_mgr.setDeltafile(media, Pathname());
283  break;
284  }
285  catch ( media::MediaException & excp )
286  {
287  ZYPP_CAUGHT(excp);
288  if (deltafileset)
289  media_mgr.setDeltafile(media, Pathname());
291  unsigned int devindex = 0;
292  std::vector<std::string> devices;
293  media_mgr.getDetectedDevices(media, devices, devindex);
294 
295  do
296  {
297  if (user != media::MediaChangeReport::EJECT) // no use in calling this again
298  {
299  DBG << "Media couldn't provide file " << file << " , releasing." << endl;
300  try
301  {
302  media_mgr.release(media);
303  }
304  catch (const Exception & excpt_r)
305  {
306  ZYPP_CAUGHT(excpt_r);
307  MIL << "Failed to release media " << media << endl;
308  }
309  }
310 
311  // set up the reason
313 
314  if( typeid(excp) == typeid( media::MediaFileNotFoundException ) ||
315  typeid(excp) == typeid( media::MediaNotAFileException ) )
316  {
318  }
319  else if( typeid(excp) == typeid( media::MediaNotDesiredException) ||
320  typeid(excp) == typeid( media::MediaNotAttachedException) )
321  {
323  }
324  else if( typeid(excp) == typeid( media::MediaTimeoutException) ||
325  typeid(excp) == typeid( media::MediaTemporaryProblemException))
326  {
328  }
329 
330  // Propagate the original error if _no_ callback receiver is connected, or
331  // non_interactive mode (for optional files) is used (except for wrong media).
333  || (( options & PROVIDE_NON_INTERACTIVE ) && reason != media::MediaChangeReport::WRONG ) )
334  {
335  MIL << "Can't provide file. Non-Interactive mode." << endl;
336  ZYPP_RETHROW(excp);
337  }
338  else
339  {
340  // release all media before requesting another (#336881)
341  media_mgr.releaseAll();
342 
343  user = report->requestMedia (
344  _url,
345  media_nr,
346  _label,
347  reason,
348  excp.asUserHistory(),
349  devices,
350  devindex
351  );
352  }
353 
354  MIL << "ProvideFile exception caught, callback answer: " << user << endl;
355 
356  if( user == media::MediaChangeReport::ABORT )
357  {
358  DBG << "Aborting" << endl;
359  AbortRequestException aexcp("Aborting requested by user");
360  aexcp.remember(excp);
361  ZYPP_THROW(aexcp);
362  }
363  else if ( user == media::MediaChangeReport::IGNORE )
364  {
365  DBG << "Skipping" << endl;
366  SkipRequestException nexcp("User-requested skipping of a file");
367  nexcp.remember(excp);
368  ZYPP_THROW(nexcp);
369  }
370  else if ( user == media::MediaChangeReport::EJECT )
371  {
372  DBG << "Eject: try to release" << endl;
373  try
374  {
375  media_mgr.releaseAll();
376  media_mgr.release (media, devindex < devices.size() ? devices[devindex] : "");
377  }
378  catch ( const Exception & e)
379  {
380  ZYPP_CAUGHT(e);
381  }
382  }
383  else if ( user == media::MediaChangeReport::RETRY ||
385  {
386  // retry
387  DBG << "Going to try again" << endl;
388  // invalidate current media access id
389  media_mgr.close(media);
390  _medias.erase(media_nr);
391 
392  // not attaching, media set will do that for us
393  // this could generate uncaught exception (#158620)
394  break;
395  }
396  else
397  {
398  DBG << "Don't know, let's ABORT" << endl;
399  ZYPP_RETHROW ( excp );
400  }
401  } while( user == media::MediaChangeReport::EJECT );
402  }
403 
404  // retry or change URL
405  } while( true );
406  }
407 
409  bool recursive,
410  unsigned media_nr,
411  ProvideFileOptions options )
412  {
413  OnMediaLocation resource;
414  resource.setLocation(dir, media_nr);
415  if ( recursive )
416  {
418  provide( boost::ref(op), resource, options, Pathname());
419  return op.result;
420  }
422  provide( boost::ref(op), resource, options, Pathname());
423  return op.result;
424  }
425 
427  {
428  if ( _medias.find( medianr ) != _medias.end() )
429  {
430  return _medias[medianr];
431  }
432 
433  Url url( medianr > 1 ? rewriteUrl( _url, medianr ) : _url );
434  media::MediaManager media_mgr;
435  media::MediaAccessId id = media_mgr.open( url, _prefAttachPoint );
436  _medias[medianr] = id;
437 
438  try
439  {
440  if ( _verifiers.find(medianr) != _verifiers.end() )
441  {
442  // a verifier is set for this media
443  // FIXME check the case where the verifier exists
444  // but we have no access id for the media
445  media_mgr.delVerifier( id );
446  media_mgr.addVerifier( id, _verifiers[medianr] );
447  // remove any saved verifier for this media
448  _verifiers.erase( medianr );
449  }
450  }
451  catch ( const Exception &e )
452  {
453  ZYPP_CAUGHT(e);
454  WAR << "Verifier not found" << endl;
455  }
456 
457  return id;
458  }
459 
460 
461  Url MediaSetAccess::rewriteUrl (const Url & url_r, const media::MediaNr medianr)
462  {
463  std::string scheme = url_r.getScheme();
464  if (scheme == "cd" || scheme == "dvd")
465  return url_r;
466 
467  DBG << "Rewriting url " << url_r << endl;
468 
469  if( scheme == "iso")
470  {
471  // TODO the iso parameter will not be required in the future, this
472  // code has to be adapted together with the MediaISO change.
473  // maybe some MediaISOURL interface should be used.
474  std::string isofile = url_r.getQueryParam("iso");
475  str::regex e("^(.*)(cd|dvd|media)[0-9]+\\.iso$", str::regex::icase);
476 
477  str::smatch what;
478  if(str::regex_match(isofile, what, e))
479  {
480  Url url( url_r);
481  isofile = what[1] + what[2] + str::numstring(medianr) + ".iso";
482  url.setQueryParam("iso", isofile);
483  DBG << "Url rewrite result: " << url << endl;
484  return url;
485  }
486  }
487  else
488  {
489  std::string pathname = url_r.getPathName();
490  str::regex e("^(.*)(cd|dvd|media)[0-9]+(/)?$", str::regex::icase);
491  str::smatch what;
492  if(str::regex_match(pathname, what, e))
493  {
494  Url url( url_r);
495  pathname = what[1] + what[2] + str::numstring(medianr) + what[3];
496  url.setPathName(pathname);
497  DBG << "Url rewrite result: " << url << endl;
498  return url;
499  }
500  }
501  return url_r;
502  }
503 
505  {
506  DBG << "Releasing all media IDs held by this MediaSetAccess" << endl;
507  media::MediaManager manager;
508  for (MediaMap::const_iterator m = _medias.begin(); m != _medias.end(); ++m)
509  manager.release(m->second, "");
510  }
511 
512  std::ostream & MediaSetAccess::dumpOn( std::ostream & str ) const
513  {
514  str << "MediaSetAccess (URL='" << _url << "', attach_point_hint='" << _prefAttachPoint << "')";
515  return str;
516  }
517 
519 } // namespace zypp
zypp::ProvideFileOperation::operator()
void operator()(media::MediaAccessId media, const Pathname &file)
Definition: MediaSetAccess.cc:115
zypp::ProvideFileExistenceOperation::ProvideFileExistenceOperation
ProvideFileExistenceOperation()
Definition: MediaSetAccess.cc:148
zypp::MediaSetAccess::_label
std::string _label
Definition: MediaSetAccess.h:373
zypp::media::MediaManager::releaseFile
void releaseFile(MediaAccessId accessId, const Pathname &filename) const
FIXME: see MediaAccess class.
Definition: MediaManager.cc:694
zypp::MediaSetAccess::_url
Url _url
Media or media set URL.
Definition: MediaSetAccess.h:363
zypp::media::MediaNr
unsigned int MediaNr
Definition: MediaManager.h:41
zypp::MediaSetAccess::PROVIDE_NON_INTERACTIVE
@ PROVIDE_NON_INTERACTIVE
Definition: MediaSetAccess.h:120
zypp::media::MediaChangeReport::Error
Error
Definition: ZYppCallbacks.h:307
zypp::MediaSetAccess::provideOptionalFile
Pathname provideOptionalFile(const Pathname &file, unsigned media_nr=1)
Provides an optional file from media media_nr.
Definition: MediaSetAccess.cc:178
zypp::Url::getScheme
std::string getScheme() const
Returns the scheme name of the URL.
Definition: Url.cc:528
zypp::filesystem::TmpFile::asManagedFile
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
Definition: TmpPath.cc:230
zypp::ProvideFileExistenceOperation
Definition: MediaSetAccess.cc:146
TmpPath.h
PathInfo.h
zypp::media::MediaException
Just inherits Exception to separate media exceptions.
Definition: MediaException.h:36
zypp::ProvideFileExistenceOperation::operator()
void operator()(media::MediaAccessId media, const Pathname &file)
Definition: MediaSetAccess.cc:152
zypp::media::MediaManager::isAttached
bool isAttached(MediaAccessId accessId) const
Check if media is attached or not.
Definition: MediaManager.cc:526
zypp::MediaSetAccess::_medias
MediaMap _medias
Mapping between media number and Media Access ID.
Definition: MediaSetAccess.h:379
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
zypp::media::MediaManager::releaseAll
void releaseAll()
Release all attached media.
Definition: MediaManager.cc:482
zypp::callback::SendReport
Definition: Callback.h:237
zypp::media::MediaFileNotFoundException
Definition: MediaException.h:146
zypp::Url::setQueryParam
void setQueryParam(const std::string &param, const std::string &value)
Set or add value for the specified query parameter.
Definition: Url.cc:833
zypp::media::MediaChangeReport::INVALID
@ INVALID
Definition: ZYppCallbacks.h:311
zypp::MediaSetAccess::provideFileFromUrl
static ManagedFile provideFileFromUrl(const Url &file_url, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides file from url.
Definition: MediaSetAccess.cc:192
zypp::MediaSetAccess::release
void release()
Release all attached media of this set.
Definition: MediaSetAccess.cc:504
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition: ManagedFile.h:27
MIL
#define MIL
Definition: Logger.h:79
zypp::MediaSetAccess::doesFileExist
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
Definition: MediaSetAccess.cc:223
zypp::media::MediaTimeoutException
Definition: MediaException.h:477
zypp::MediaSetAccess::_prefAttachPoint
Pathname _prefAttachPoint
Prefered mount point.
Definition: MediaSetAccess.h:371
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition: OnMediaLocation.h:39
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:392
zypp::ProvideFileExistenceOperation::result
bool result
Definition: MediaSetAccess.cc:147
zypp::media::MediaManager::attach
void attach(MediaAccessId accessId)
Attach the media using the concrete handler (checks all devices).
Definition: MediaManager.cc:372
zypp::MediaSetAccess::rewriteUrl
static Url rewriteUrl(const Url &url_r, const media::MediaNr medianr)
Replaces media number in specified url with given medianr.
Definition: MediaSetAccess.cc:461
zypp::media::MediaManager::delVerifier
void delVerifier(MediaAccessId accessId)
Remove verifier for specified media id.
Definition: MediaManager.cc:352
zypp::str::regex::icase
@ icase
Do not differentiate case.
Definition: Regex.h:99
zypp::media::MediaManager::setDeltafile
void setDeltafile(MediaAccessId accessId, const Pathname &filename) const
Definition: MediaManager.cc:649
zypp::media::MediaChangeReport::IGNORE
@ IGNORE
Definition: ZYppCallbacks.h:301
zypp::ByteCount
Store and operate with byte count.
Definition: ByteCount.h:31
zypp::media::MediaAccessId
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
zypp::Url::getQueryParam
std::string getQueryParam(const std::string &param, EEncoding eflag=zypp::url::E_DECODED) const
Return the value for the specified query parameter.
Definition: Url.cc:655
zypp::ProvideDirOperation::operator()
void operator()(media::MediaAccessId media, const Pathname &file)
Definition: MediaSetAccess.cc:137
zypp::OnMediaLocation::medianr
unsigned medianr() const
The media number the resource is located on.
Definition: OnMediaLocation.cc:88
zypp::ProvideDirOperation
Definition: MediaSetAccess.cc:135
zypp::media::MediaManager::provideDirTree
void provideDirTree(MediaAccessId accessId, const Pathname &dirname) const
FIXME: see MediaAccess class.
Definition: MediaManager.cc:682
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
LogTools.h
zypp::MediaSetAccess::releaseFile
void releaseFile(const OnMediaLocation &resource)
Release file from media.
Definition: MediaSetAccess.cc:77
zypp::media::MediaManager::isOpen
bool isOpen(MediaAccessId accessId) const
Query if the media access is open / exists.
Definition: MediaManager.cc:299
zypp::media::MediaNotDesiredException
Definition: MediaException.h:378
zypp::MediaSetAccess::dirInfo
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
Definition: MediaSetAccess.cc:97
zypp::Exception::asUserHistory
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Definition: Exception.cc:91
zypp::MediaSetAccess::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: MediaSetAccess.cc:512
zypp::media::MediaNotAFileException
Definition: MediaException.h:236
zypp::Url::setPathName
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
Definition: Url.cc:759
WAR
#define WAR
Definition: Logger.h:80
zypp::MediaSetAccess::~MediaSetAccess
~MediaSetAccess()
Definition: MediaSetAccess.cc:46
zypp::media::MediaNotAttachedException
Definition: MediaException.h:177
zypp::media::MediaManager
Manages access to the 'physical' media, e.g CDROM drives, Disk volumes, directory trees,...
Definition: MediaManager.h:472
zypp::media::MediaChangeReport::CHANGE_URL
@ CHANGE_URL
Definition: ZYppCallbacks.h:303
zypp::ProvideFileOperation::expectedFileSize
ByteCount expectedFileSize
Definition: MediaSetAccess.cc:114
ZYppCallbacks.h
zypp::OnMediaLocation::downloadSize
const ByteCount & downloadSize() const
The size of the resource on the server.
Definition: OnMediaLocation.cc:112
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::media::MediaManager::open
MediaAccessId open(const Url &url, const Pathname &preferred_attach_point="")
Opens the media access for specified with the url.
Definition: MediaManager.cc:245
zypp::filesystem::DirContent
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:547
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition: String.h:286
zypp::media::MediaChangeReport::EJECT
@ EJECT
Definition: ZYppCallbacks.h:304
zypp::MediaSetAccess::ProvideOperation
function< void(media::MediaAccessId, const Pathname &)> ProvideOperation
Definition: MediaSetAccess.h:354
zypp::media::MediaManager::provideDir
void provideDir(MediaAccessId accessId, const Pathname &dirname) const
FIXME: see MediaAccess class.
Definition: MediaManager.cc:670
zypp::MediaSetAccess::PROVIDE_DEFAULT
@ PROVIDE_DEFAULT
The user is not asked anything, and the error exception is just propagated.
Definition: MediaSetAccess.h:119
Regex.h
zypp::ProvideDirTreeOperation
Definition: MediaSetAccess.cc:124
zypp::IMPL_PTR_TYPE
IMPL_PTR_TYPE(Application)
zypp::media::MediaChangeReport::Action
Action
Definition: ZYppCallbacks.h:298
zypp::media::MediaManager::localPath
Pathname localPath(MediaAccessId accessId, const Pathname &pathname) const
Shortcut for 'localRoot() + pathname', but returns an empty pathname if media is not attached.
Definition: MediaManager.cc:617
zypp::OnMediaLocation::setLocation
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
Definition: OnMediaLocation.cc:91
zypp::ProvideFileOperation::result
Pathname result
Definition: MediaSetAccess.cc:113
zypp::str::smatch
Regular expression match result.
Definition: Regex.h:161
zypp::media::MediaChangeReport::ABORT
@ ABORT
Definition: ZYppCallbacks.h:299
zypp::OnMediaLocation::filename
const Pathname & filename() const
The path to the resource on the medium.
Definition: OnMediaLocation.cc:85
zypp::media::MediaChangeReport::IO_SOFT
@ IO_SOFT
IO error which can happen on worse connection like timeout exceed.
Definition: ZYppCallbacks.h:313
zypp::MediaSetAccess::_verifiers
VerifierMap _verifiers
Mapping between media number and corespondent verifier.
Definition: MediaSetAccess.h:381
zypp::ProvideDirOperation::result
Pathname result
Definition: MediaSetAccess.cc:136
zypp::media::MediaManager::close
void close(MediaAccessId accessId)
Close the media access with specified id.
Definition: MediaManager.cc:265
zypp::media::MediaManager::addVerifier
void addVerifier(MediaAccessId accessId, const MediaVerifierRef &verifier)
Add verifier implementation for the specified media id.
Definition: MediaManager.cc:335
UserRequestException.h
zypp::media::MediaChangeReport::NOT_FOUND
@ NOT_FOUND
Definition: ZYppCallbacks.h:309
zypp::ProvideDirTreeOperation::operator()
void operator()(media::MediaAccessId media, const Pathname &file)
Definition: MediaSetAccess.cc:126
zypp::ProvideFileOperation
Definition: MediaSetAccess.cc:112
zypp::MediaSetAccess::setVerifier
void setVerifier(unsigned media_nr, media::MediaVerifierRef verifier)
Sets a MediaVerifier verifier for given media number.
Definition: MediaSetAccess.cc:58
zypp::media::MediaManager::doesFileExist
bool doesFileExist(MediaAccessId accessId, const Pathname &filename) const
FIXME: see MediaAccess class.
Definition: MediaManager.cc:761
zypp::ProvideDirTreeOperation::result
Pathname result
Definition: MediaSetAccess.cc:125
zypp::Url::getPathName
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
Definition: Url.cc:599
ZYPP_RETHROW
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
Definition: Exception.h:400
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:93
zypp::media::MediaManager::release
void release(MediaAccessId accessId, const std::string &ejectDev="")
Release the attached media and optionally eject.
Definition: MediaManager.cc:440
zypp::media::MediaManager::precacheFiles
void precacheFiles(MediaAccessId accessId, const std::vector< OnMediaLocation > &files)
Tries to fetch the given files and precaches them.
Definition: MediaManager.cc:659
zypp::media::MediaChangeReport::RETRY
@ RETRY
Definition: ZYppCallbacks.h:300
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::media::MediaManager::dirInfo
void dirInfo(MediaAccessId accessId, std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
FIXME: see MediaAccess class.
Definition: MediaManager.cc:731
verifier
MediaVerifierRef verifier
Definition: MediaManager.cc:104
zypp::media::MediaManager::getDetectedDevices
void getDetectedDevices(MediaAccessId accessId, std::vector< std::string > &devices, unsigned int &index) const
Fill in a vector of detected ejectable devices and the index of the currently attached device within ...
Definition: MediaManager.cc:773
DBG
#define DBG
Definition: Logger.h:78
zypp::MediaSetAccess::provideFile
Pathname provideFile(const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT, const Pathname &deltafile=Pathname())
Provides a file from a media location.
Definition: MediaSetAccess.cc:161
zypp::str::regex_match
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition: Regex.h:70
zypp::MediaSetAccess
Media access layer responsible for handling files distributed on a set of media with media change and...
Definition: MediaSetAccess.h:81
str
String related utilities and Regular expression matching.
zypp::filesystem::hardlinkCopy
int hardlinkCopy(const Pathname &oldpath, const Pathname &newpath)
Create newpath as hardlink or copy of oldpath.
Definition: PathInfo.cc:836
ZYPP_CAUGHT
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:396
MediaSetAccess.h
zypp::MediaSetAccess::provide
void provide(ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile)
Definition: MediaSetAccess.cc:253
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition: Pathname.h:91
zypp::MediaSetAccess::provideDir
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
Definition: MediaSetAccess.cc:408
zypp::Url
Url manipulation class.
Definition: Url.h:88
zypp::media::MediaManager::provideFile
void provideFile(MediaAccessId accessId, const Pathname &filename, const ByteCount &expectedFileSize) const
Provide provide file denoted by relative path below of the 'attach point' of the specified media and ...
Definition: MediaManager.cc:628
zypp::str::regex
Regular expression.
Definition: Regex.h:95
zypp::MediaSetAccess::precacheFiles
void precacheFiles(const std::vector< OnMediaLocation > &files)
Tries to fetch the given files and precaches them.
Definition: MediaSetAccess.cc:232
zypp::MediaSetAccess::provideOptionalFileFromUrl
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
Definition: MediaSetAccess.cc:210
zypp::media::MediaChangeReport::WRONG
@ WRONG
Definition: ZYppCallbacks.h:312
zypp::MediaSetAccess::MediaSetAccess
MediaSetAccess(const Url &url, const Pathname &prefered_attach_point="")
Creates a callback enabled media access for specified url.
Definition: MediaSetAccess.cc:32
zypp::MediaSetAccess::getMediaAccessId
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
Definition: MediaSetAccess.cc:426
zypp::OnMediaLocation::optional
bool optional() const
Whether this is an optional resource.
Definition: OnMediaLocation.cc:106
zypp::media::MediaTemporaryProblemException
For HTTP 503 and similar.
Definition: MediaException.h:509