Sha256: 8d1c26492b2842461a8a61b7fb51cb565c5cb8c76e6cbb432795e12b1427f928

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

require 'zlib'

require "massive_sitemap/writer/file"
# Create Lock before writing to file

module MassiveSitemap
  module Writer

    class LockingFile < File
      LOCK_FILE = 'generator.lock'

      def open_stream
        ::File.open(LOCK_FILE, 'w', ::File::EXCL) #lock!
        super
      end

      def close_stream(stream)
        super
        FileUtils.rm(LOCK_FILE) #unlock!
      end

      def init?
        if ::File.exists?(LOCK_FILE)
          raise Errno::EACCES
        end
        super
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
massive_sitemap-2.0.0.rc1 lib/massive_sitemap/writer/locking_file.rb