libzypp  17.31.31
initial_p.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 ----------------------------------------------------------------------*/
9 
12 
13 #include "initial_p.h"
14 #if ENABLE_ZCHUNK_COMPRESSION
15 #include "zck_p.h"
16 #endif
17 
18 namespace zyppng {
19 
20  void InitialState::enter(){ MIL_MEDIA << "Entering initial state" << std::endl; }
21 
22  void InitialState::exit(){ MIL_MEDIA << "Leaving initial state" << std::endl; }
23 
25  {
26  auto &sm = stateMachine();
27  const auto &spec = sm._spec;
28 
29  if ( spec.checkExistsOnly() ) {
30  MIL_MEDIA << "Check exists only enabled" << std::endl;
32  }
33 
34 #if ENABLE_ZCHUNK_COMPRESSION
35  bool deltaZck = isZchunkFile( spec.deltaFile() );
36 #endif
37  if ( spec.metalinkEnabled() ) {
38 #if ENABLE_ZCHUNK_COMPRESSION
39  if ( deltaZck && spec.headerSize() > 0 ) {
40  MIL_MEDIA << "We might have a zck file, detecting metalink first" << std::endl;
42  }
43 #endif
44  MIL_MEDIA << "No zchunk data available but metalink requested, going to download metalink directly." << std::endl;
46  }
47 
48 #if ENABLE_ZCHUNK_COMPRESSION
49  // no Metalink, maybe we can directly download zck
50  if ( deltaZck && spec.headerSize() > 0 ) {
51  MIL_MEDIA << "No metalink but zckunk data availble trying to download ZckHead directly." << std::endl;
52  return _sigTransitionToDLZckHeaderState.emit();
53  }
54 #endif
55  MIL_MEDIA << "Fallback to normal DL" << std::endl;
57  }
58 
59 #if ENABLE_ZCHUNK_COMPRESSION
60  std::shared_ptr<DLZckHeadState> InitialState::toDLZckHeadState()
61  {
62  // we have no mirrors, the range downloader would need to fall back to using the base URL
63  return std::make_shared<DLZckHeadState>( std::vector<Url> { stateMachine()._spec.url() }, stateMachine() );
64  }
65 #endif
66 
67 
68 }
Signal< void()> _sigTransitionToDetectMetalinkState
Definition: initial_p.h:61
Signal< void()> _sigTransitionToDlNormalFileState
Definition: initial_p.h:66
Signal< void()> _sigTransitionToDlMetaLinkInfoState
Definition: initial_p.h:62
#define MIL_MEDIA
Definition: mediadebug_p.h:29