You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just add few lines of code in Open method and add CoumputeMD5 method:
DIR: tango/restful-tango/tangoREST.py
defcomputeMD5(self, directory):
""" computeMD5 - Computes the MD5 hash of given files in the given directory """result= {}
foreleminos.listdir(directory):
try:
body=open("%s/%s"% (directory, elem)).read()
md5hash=hashlib.md5(body).hexdigest()
result[elem] =md5hashexceptIOError:
continuereturnresultdefopen(self, key, courselab):
""" open - Return a dict of md5 hashes for each input file in the key-courselab directory and make one if the directory doesn't exist """self.log.debug("Received open request(%s, %s)"% (key, courselab))
ifself.validateKey(key):
labPath=self.getDirPath(key, courselab)
try:
ifos.path.exists(labPath):
self.log.info(
"Found directory for (%s, %s)"% (key, courselab))
statusObj=self.status.found_dirstatusObj['files'] =self.computeMD5(labPath)
returnstatusObjelse:
outputPath=self.getOutPath(key, courselab)
os.makedirs(outputPath)
self.log.info(
"Created directory for (%s, %s)"% (key, courselab))
statusObj=self.status.made_dirstatusObj["files"] = {}
returnstatusObjexceptExceptionase:
self.log.error("open request failed: %s"%str(e))
returnself.status.create(-1, str(e))
else:
self.log.info("Key not recognized: %s"%key)
returnself.status.wrong_key
The text was updated successfully, but these errors were encountered:
Thanks for pointing this out! I believe the behavior was modified in #113. Instead of computing hashes of files in open, restful-tango just has the client upload all its files, and it simply ignores the ones it already have.
However, it seems this would result in more md5 computations server-side, as well as many unnecessary uploads. I'm going to make a fix soon.
Expected Behavior
According to documentation, when I am getting into /open I suppose to see:
{
"statusMsg": ,
"statusId": ,
"files": { : , : ... },
}
Actual Behavior
When getting into /open request, it returns only StatusMsg and StatusId, Files are always empty even if there is any file in courselab directory:
{
"statusMsg": "Found directory",
"statusId": "0"
"files": { },
}
Steps to Reproduce the Behavior
Just add few lines of code in Open method and add CoumputeMD5 method:
DIR: tango/restful-tango/tangoREST.py
The text was updated successfully, but these errors were encountered: