mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	git-linguist: Do not write cache if repo is gone
This commit is contained in:
		@@ -71,17 +71,20 @@ class GitLinguist
 | 
				
			|||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def write_cache(object)
 | 
					  def write_cache(object)
 | 
				
			||||||
    tmp_path = Dir::Tmpname.make_tmpname(cache_file, nil)
 | 
					    return unless File.directory? @repo_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    begin
 | 
				
			||||||
 | 
					      tmp_path = Dir::Tmpname.make_tmpname(cache_file, nil)
 | 
				
			||||||
      File.open(tmp_path, "wb") do |f|
 | 
					      File.open(tmp_path, "wb") do |f|
 | 
				
			||||||
        marshal = Marshal.dump(object)
 | 
					        marshal = Marshal.dump(object)
 | 
				
			||||||
        f.write(Zlib::Deflate.deflate(marshal))
 | 
					        f.write(Zlib::Deflate.deflate(marshal))
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      File.rename(tmp_path, cache_file)
 | 
					      File.rename(tmp_path, cache_file)
 | 
				
			||||||
    tmp_path = nil
 | 
					    rescue => e
 | 
				
			||||||
  ensure
 | 
					      (File.unlink(tmp_path) rescue nil)
 | 
				
			||||||
    (File.unlink(tmp_path) rescue nil) if tmp_path
 | 
					      raise e
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def load_cache
 | 
					  def load_cache
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user