@@ -219,40 +219,46 @@ def get_manifest_patch(
219219 return patches
220220
221221 def config_string (self , name : str ) -> str :
222- """Convert configuration oblect to string representation.
222+ """Convert configuration object to string representation.
223223
224224 Needed to create RClone compatible INI files.
225225 """
226226 if not self .configuration :
227227 raise ValidationError ("Missing configuration for cloud storage" )
228-
229- # Transform configuration for polybox or switchDrive
228+ # TODO Use RCloneValidator.get_real_configuration(...) instead.
229+ real_config = dict (self .configuration )
230+ # Transform configuration for polybox, switchDrive or openBIS
230231 storage_type = self .configuration .get ("type" , "" )
231232 access = self .configuration .get ("provider" , "" )
232233
233234 if storage_type == "polybox" or storage_type == "switchDrive" :
234- self .configuration ["type" ] = "webdav"
235- self .configuration ["provider" ] = ""
235+ real_config ["type" ] = "webdav"
236+ real_config ["provider" ] = ""
237+ elif storage_type == "s3" and access == "Switch" :
238+ # Switch is a fake provider we add for users, we need to replace it since rclone itself
239+ # doesn't know it
240+ real_config ["provider" ] = "Other"
241+ elif storage_type == "openbis" :
242+ real_config ["type" ] = "sftp"
243+ real_config ["port" ] = "2222"
244+ real_config ["user" ] = "?"
245+ real_config ["pass" ] = real_config .pop ("session_token" )
236246
237247 if access == "shared" and storage_type == "polybox" :
238- self . configuration ["url" ] = "https://polybox.ethz.ch/public.php/webdav/"
248+ real_config ["url" ] = "https://polybox.ethz.ch/public.php/webdav/"
239249 elif access == "shared" and storage_type == "switchDrive" :
240- self . configuration ["url" ] = "https://drive.switch.ch/public.php/webdav/"
250+ real_config ["url" ] = "https://drive.switch.ch/public.php/webdav/"
241251 elif access == "personal" and storage_type == "polybox" :
242- self . configuration ["url" ] = "https://polybox.ethz.ch/remote.php/webdav/"
252+ real_config ["url" ] = "https://polybox.ethz.ch/remote.php/webdav/"
243253 elif access == "personal" and storage_type == "switchDrive" :
244- self . configuration ["url" ] = "https://drive.switch.ch/remote.php/webdav/"
254+ real_config ["url" ] = "https://drive.switch.ch/remote.php/webdav/"
245255
246256 # Extract the user from the public link
247257 if access == "shared" and storage_type in {"polybox" , "switchDrive" }:
248258 public_link = self .configuration .get ("public_link" , "" )
249259 user_identifier = public_link .split ("/" )[- 1 ]
250- self . configuration ["user" ] = user_identifier
260+ real_config ["user" ] = user_identifier
251261
252- if self .configuration ["type" ] == "s3" and self .configuration .get ("provider" , None ) == "Switch" :
253- # Switch is a fake provider we add for users, we need to replace it since rclone itself
254- # doesn't know it
255- self .configuration ["provider" ] = "Other"
256262 parser = ConfigParser ()
257263 parser .add_section (name )
258264
@@ -261,7 +267,7 @@ def _stringify(value: Any) -> str:
261267 return "true" if value else "false"
262268 return str (value )
263269
264- for k , v in self . configuration .items ():
270+ for k , v in real_config .items ():
265271 parser .set (name , k , _stringify (v ))
266272 stringio = StringIO ()
267273 parser .write (stringio )
0 commit comments