#546 Check whether sources file is not a directory
Merged 3 years ago by onosek. Opened 3 years ago by onosek.
onosek/rpkg sources_dir  into  master

file modified
+7
@@ -31,6 +31,13 @@ 

          self.entry_type = {'old': SourceFileEntry,

                             'bsd': BSDSourceFileEntry}[entry_type]

          self.entries = []

+         # if there is a directory with the same name, it causes a collision

+         # during reading the file and during its replacing as well

+         if os.path.exists(sourcesfile) and os.path.isdir(sourcesfile):

+             raise ValueError(

+                 "'{0}' has to be a regular file, not a directory. The '{0}' "

+                 "filename is a rpkg library default name or a specific layout "

+                 " setting)".format(sourcesfile))

  

          if not replace:

              if not os.path.exists(sourcesfile):

file modified
+4
@@ -268,3 +268,7 @@ 

  

          self.assertEqual(len(lines), 1)

          self.assertEqual(lines[0], 'MD5 (thirdfile) = thirdhash\n')

+ 

+     def test_directory_instead_of_regular_file(self):

+         os.mkdir(self.sourcesfile)

+         self.assertRaises(ValueError, sources.SourcesFile, self.sourcesfile, 'bsd')

Resolves: #541
JIRA: RHELCMP-4166

Signed-off-by: Ondrej Nosek onosek@redhat.com

Pull-Request has been merged by onosek

3 years ago