Skip to content
Snippets Groups Projects
Commit 3c3d44d1 authored by srsdanny's avatar srsdanny
Browse files

Van zárolás

parent 82c26ffd
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,9 @@ bool CloudFileSystem::deleteFile(FileDescriptor fileDescriptor) { ...@@ -78,6 +78,9 @@ bool CloudFileSystem::deleteFile(FileDescriptor fileDescriptor) {
if (findByID(&fileDescriptor) != NULL){ if (findByID(&fileDescriptor) != NULL){
FileDescriptor* fileOnCloud = findByID(&fileDescriptor); FileDescriptor* fileOnCloud = findByID(&fileDescriptor);
if (!isLocked(*fileOnCloud))
{
if (application.cal.deleteFile(*fileOnCloud)){ if (application.cal.deleteFile(*fileOnCloud)){
if (delFromFileTreeByID(fileOnCloud)){ if (delFromFileTreeByID(fileOnCloud)){
cfl.save(); cfl.save();
...@@ -85,6 +88,11 @@ bool CloudFileSystem::deleteFile(FileDescriptor fileDescriptor) { ...@@ -85,6 +88,11 @@ bool CloudFileSystem::deleteFile(FileDescriptor fileDescriptor) {
} }
} }
} }
else
{
std::cerr << "File is locked" << endl;
}
}
return false; return false;
} }
......
...@@ -164,8 +164,6 @@ public: ...@@ -164,8 +164,6 @@ public:
* Retrieves fileDescriptor from the fileTree * Retrieves fileDescriptor from the fileTree
*/ */
FileDescriptor* findByID(FileDescriptor* fileDescriptor); FileDescriptor* findByID(FileDescriptor* fileDescriptor);
private:
CloudFileList cfl;
/** /**
* Creates a lock on a given file. * Creates a lock on a given file.
...@@ -185,6 +183,8 @@ private: ...@@ -185,6 +183,8 @@ private:
* @return true if any of the fragments are locked, false otherwise * @return true if any of the fragments are locked, false otherwise
*/ */
bool isLocked(FileDescriptor fileDescriptor); bool isLocked(FileDescriptor fileDescriptor);
private:
CloudFileList cfl;
}; };
#endif //_CLOUDFILESYSTEM_H #endif //_CLOUDFILESYSTEM_H
\ No newline at end of file
...@@ -45,7 +45,18 @@ string ComputeOnClient::getFile(FileDescriptor fileDescriptor) { ...@@ -45,7 +45,18 @@ string ComputeOnClient::getFile(FileDescriptor fileDescriptor) {
return "Clouds doesn't contain the file."; return "Clouds doesn't contain the file.";
} else { } else {
FileDescriptor* fileToDownload = cloudFileSystem.findByID(&fileDescriptor); FileDescriptor* fileToDownload = cloudFileSystem.findByID(&fileDescriptor);
if (!cloudFileSystem.isLocked(*fileToDownload))
{
cloudFileSystem.lock(*fileToDownload);
FileDescriptor* downloaded = cloudFileSystem.getCloudAccessLayer()->download(*fileToDownload); FileDescriptor* downloaded = cloudFileSystem.getCloudAccessLayer()->download(*fileToDownload);
cloudFileSystem.unlock(*fileToDownload);
return Decoder::decode(downloaded); return Decoder::decode(downloaded);
} }
else
{
std::cerr << "File is locked" << endl;
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment