-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
617 handle file deletion #1075
617 handle file deletion #1075
Conversation
@@ -209,6 +213,16 @@ def suspended_save_ontologies(options={}) | |||
schedule_batch_parsing(versions) | |||
end | |||
|
|||
def mark_ontology_as_having_file(path, has_file) | |||
ontos = ontologies.with_path(path) | |||
if ontos.any?{ |onto| onto.has_file != has_file } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.
Style/SpaceBeforeBlockBraces: Space missing to the left of {.
ddff130
to
8afba41
Compare
@@ -55,4 +55,10 @@ def status(resource) | |||
html | |||
end | |||
|
|||
def last_file_path(resource) | |||
repository_ref_path(repository_id: resource.repository.to_param, | |||
ref: resource.current_version.commit_oid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/AlignHash: Align the elements of a hash literal if they span more than one line.
22a29d8
to
8bbf5c7
Compare
e9bb215
to
5931d1e
Compare
|
||
def has_file(commit_oid = nil) | ||
if repository.is_head?(commit_oid) | ||
read_attribute(:has_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails/ReadWriteAttribute: Prefer self[:attr]
over read_attribute(:attr)
.
d3dec09
to
f256897
Compare
f256897
to
771d584
Compare
redirect_to fancy_repository_path(repository, path: resource.target_path) | ||
else | ||
render :show | ||
end | ||
end | ||
|
||
def destroy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for destroy is too high. [16/15]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a hound/rubocop bug or I just don't understand this comment. There is no branching in this method.
I'm ignoring the hound comments on |
dir = nil | ||
Array(0..dirs.length - 1).reverse.each do |i| | ||
if dir.nil? | ||
path = dirs[0..i].join('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
cca0a1d
to
f792d42
Compare
please rebase staging. |
end | ||
|
||
it 'create a new ontology version' do | ||
expect(repository.ontologies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation and line-breaks seem strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 69b618d.
Tests are red because #1343's commits are not in here. |
So tests should be green if i merge #1343 locally and then run the tests? |
Yes. And if you have the latest hets version (v0.99, 1430921534), of course. |
👍 |
Before, the file was not found in the index because the tree was only loaded when a commit changed or added a file. It has to be loaded when a commit deletes a file as well, to find that file.
d4433c9
to
d2f6297
Compare
This shall fix #617 and #958.
Files in the repository can be deleted now via the web interface.
Then, their ontologies will be marked as 'not having a file' (
has_file
).This flag is stored in the database, but only for the head-version of an ontology (as a cache).
One can still ask for a specific commit, if an ontology has a file (
has_file(commit_oid)
), which then accesses the hard drive.Deletion via ssh is detected and the flag is set in that case.
In the view (ontology#show), the nonexistence of a corresponding file is indicated by text and the absence of a link to the file.