Cytomine-core icon indicating copy to clipboard operation
Cytomine-core copied to clipboard

Software upload failure

Open yasushinj opened this issue 4 years ago • 1 comments

pushing a file from python client, cytomine core : RestSoftwareController.groovy is failing at the following code. parent directory with softare,id should be tested whether or not directory, if it is not, it should go ahead to make directory and then move to create a file. Currently, it is trying to create file and then checking the parent directory, so it is destined to fail if the directory does not exist upon file creation.

                String sourcePath = software.id+"/"+filename
                File source = new File((grailsApplication.config.cytomine.software.path.softwareSources as String)+"/"+sourcePath)
                if(!source.parentFile.exists()) source.parentFile.mkdir()
                f.transferTo(source) 

yasushinj avatar Jun 20 '20 00:06 yasushinj

Hello,

The File object "source" is only instantiated at the line 2. In Java, you can create a File object even if the associated path doesn't exists. It will not try to create the file on your filesystem.

So, we check if the parentDirectory exists before creating the file with the line f.transferTo(source)

However, the softwareSources parameter is not into the bootstrap repository, so its default value is "/data/softwares/code"

I will fix this into the bootstrap repository because it can be the origin of some problems.

geektortoise avatar Jun 26 '20 15:06 geektortoise