Imported Upstream version 17.13.0
[platform/upstream/libzypp.git] / zypp / target / TargetImpl.cc
index 48c3c98..3fd990b 100644 (file)
@@ -1127,6 +1127,8 @@ namespace zypp
     {
       // ----------------------------------------------------------------- //
       ZYppCommitPolicy policy_r( policy_rX );
+      bool explicitDryRun = policy_r.dryRun(); // explicit dry run will trigger a fileconflict check, implicit (download-only) not.
+
       ShutdownLock lck("Zypp commit running.");
 
       // Fake outstanding YCP fix: Honour restriction to media 1
@@ -1346,12 +1348,20 @@ namespace zypp
          else
          {
            DBG << "dryRun/downloadOnly: Not installing/deleting anything." << endl;
+           if ( explicitDryRun ) {
+             // if cache is preloaded, check for file conflicts
+             commitFindFileConflicts( policy_r, result );
+           }
          }
        }
       }
       else
       {
         DBG << "dryRun: Not downloading/installing/deleting anything." << endl;
+       if ( explicitDryRun ) {
+         // if cache is preloaded, check for file conflicts
+         commitFindFileConflicts( policy_r, result );
+       }
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -1615,11 +1625,18 @@ namespace zypp
                 }
                 else
                 {
-                  PathInfo referenceFile( Pathname::assertprefix( _root, Pathname( "/etc/products.d" ) ) / referenceFilename );
-                  if ( ! referenceFile.isFile() || filesystem::unlink( referenceFile.path() ) != 0 )
-                  {
-                    ERR << "Delete orphan product failed: " << referenceFile << endl;
-                  }
+                 Pathname referencePath { Pathname("/etc/products.d") / referenceFilename };   // no root prefix for rpmdb lookup!
+                 if ( ! rpm().hasFile( referencePath.asString() ) )
+                 {
+                   // If it's not owned by a package, we can delete it.
+                   referencePath = Pathname::assertprefix( _root, referencePath );     // now add a root prefix
+                   if ( filesystem::unlink( referencePath ) != 0 )
+                     ERR << "Delete orphan product failed: " << referencePath << endl;
+                 }
+                 else
+                 {
+                   WAR << "Won't remove orphan product: '/etc/products.d/" << referenceFilename << "' is owned by a package." << endl;
+                 }
                 }
               }
             }